/etc/init.d/amc doesn't complete when run by ssh


In the AMC start script, there’s code that is supposed to start a watchdog script start_amc_cron.sh, but that script doesn’t properly detach from the shell, and as a result anything that tries to automate that script ends up hanging.

You can test this by running the script without a TTY via “ssh $host sudo /etc/init.d/amc start”. The service starts up fine, but the command never exits and ssh just hangs there. I was able to work around this (and make it pretty reliable) by using runit to monitor gnuicorn in the foreground instead. But I wasn’t able to find a good way for the background process to detach cleanly and allow ssh to close the connection. (This problem also make automation of the service via the provided script impossible for at least Salt, and likely Puppet/Chef as well.)


I will give this a quick test in house.


If you want, the following run script (for use with runit or daemontools) works really well instead:

exec 2>&1


CMD="${GUNICORN} --config=${CONFIG} flaskapp:app"

exec $CMD