elife-xpub
elife-xpub copied to clipboard
Add a wrapper script to handle signals
When running on a docker container, the /bin/sh is the main process with PID 1. According to docker documentation (https://docs.docker.com/engine/reference/run/#foreground)
Note: A process running as PID 1 inside a container is treated specially by Linux: it ignores any signal with the default action. So, the process will not terminate on SIGINT or SIGTERM unless it is coded to do so.
Hence we need to write a wrapper script to replace the current command in docker-compose script that will:
- wrap the execution of the wait-for-it.sh script
- execute the npx pubsweet server command
- listen and pass along SIGTERM to the node process
Found a blog post from codeship that should help: https://blog.codeship.com/trapping-signals-in-docker-containers/
This ticket follows from #1676