Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to start fastboot server with unix socket #46

Open
max-konin opened this issue Jan 19, 2017 · 5 comments
Open

How to start fastboot server with unix socket #46

max-konin opened this issue Jan 19, 2017 · 5 comments

Comments

@max-konin
Copy link

There is way to start fastboot r with unix socket? I have many ember apps on one server. And I have no wish to set up different port for each app.

@jeffjewiss
Copy link

Hey @max-konin, were you able to get this working?

The express docs state that you can put a path to a unix socket as the port argument.

The port argument may also be a string representing the path to a unix domain socket:
app.listen('/tmp/express.sock');

@max-konin
Copy link
Author

@jeffjewiss No. I started using docker)

@janwerkhoven
Copy link

janwerkhoven commented Oct 22, 2018

@jeffjewiss Do you have a working example how of serving Fastboot via a socket?

I'm currently using Nginx on port 8001:

node fastboot-server.js
// fastboot-server.js

/*eslint-env node*/

const FastBootAppServer = require('fastboot-app-server');

let server = new FastBootAppServer({
  distPath: 'dist',
  gzip: true,
  host: '127.0.0.1',
  port: 8001
});

server.start();
# /etc/nginx/sites-available/foo.com

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name foo.com;

  location / {
    proxy_pass http://127.0.0.1:8001;
  }
}

@jeffjewiss
Copy link

@janwerkhoven I don't think you should need to use a socket for just running Fastboot behind Nginx like that. However, if you do, you should be able to use the socket path in place of the port in your FastBootAppServer config:

let server = new FastBootAppServer({
  distPath: 'dist',
  gzip: true,
  host: '127.0.0.1',
  port: '/tmp/express.sock'
});

@janwerkhoven
Copy link

Thanks!

I've much grown to appreciate how Rails' Puma app server organises sockets:

shared/tmp/sockets/puma.sock
shared/tmp/sockets/puma.state
shared/tmp/sockets/pumactl.sock

With pumactl.sock you can control the daemonised app server puma.sock:

pumactl --control-url 'unix://pumactl.sock' stop
pumactl --control-url 'unix://pumactl.sock' restart
pumactl --control-url 'unix://pumactl.sock' stats

Even without pumactl it's easy to stop the app server:

rm puma.sock

To stop Fastboot, I've often had to resort to looking up the pid of the process that was listening to port 8000 and then kill it.

sudo lsof -iTCP -sTCP:LISTEN -P
[find pid]
kill -9 [pid]

Surely there is an easier way? 😅

Also on my server port 8000 and 8001 are already taken by 2 other Fastboot app servers, thus I chose 8002 for this project. Not a big issue, though if these were sockets, each Fastboot app would not need care about the other apps listening on the same server. Instead their sockets would be neatly organised in their respective project folders:

/var/www/foo-app/tmp/sockets/fastboot.sock

Easy to kill.

Inherits directory permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants