Entrypoint for running in production
The current pubsweet run
command has a number of drawbacks:
- Compiles assets on start
- if the app crashes, it will be down for several seconds while it recompiles
- can't host assets elsewhere
- Doesn't respond to signals (e.g.
SIGINT
kills thenpm
process but leaves the underlyingnode
process running) - Doesn't easily support clustering
- Harder to monitor
Current process hierarchy:
$ pstree -g3 (pgrep npm)
─┬= 36298 tamlyn npm
└─┬─ 36299 tamlyn node .../node_modules/.bin/pubsweet start
└─┬─ 36300 tamlyn node .../node_modules/pubsweet/bin/pubsweet-start.js
└─── 36305 tamlyn /usr/local/bin/node .../node_modules/pubsweet/src/start/index.js
I would expect to build the assets once (see pubsweet-cli#63) as part of the deployment pipeline then have a documented entrypoint which is a plain JS file that runs the app without any child processes. Then I could use pm2
or whatever process manager I'm used to.
Can kinda do this now but it's not documented and feels fragile
pm2 start node_modules/pubsweet/src/start