fastboot-app-server
fastboot-app-server copied to clipboard
How to start fastboot server with unix socket
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.
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');
@jeffjewiss No. I started using docker)
@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;
}
}
@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'
});
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.