OpenNebula / addon-context-linux

Linux VM Contextualization
Apache License 2.0
56 stars 73 forks source link

Any long running process started by `START_SCRIPT` will block OS boot #265

Closed ospalax closed 2 years ago

ospalax commented 2 years ago

START_SCRIPT is started in a subshell by one-contexd service which will block and wait for this subshell (its process child) to terminate - therefore if start script creates any long running process then it will halt the one-contexd service and OS boot.

The issue manifests with obvious example like running infinite loop in the start script (while true ; do :; done) but unfortunately this happens also in more sinister way when a command seemingly is finished and start script reach the end - the culprit in these cases are processes which fork or daemonize.

Therefore very useful commands like rc-service nginx start cause this too and cannot be used in the start script currently.

I failed to find any trick to avoid this problem - no amount of nohups, setsid, disown and any of their combination seemed to work.

Proposed solution is to not run START_SCRIPT and possibly other scripts in a subshell.

ospalax commented 2 years ago

Solved by PR:

To execute long-running processes in START_SCRIPT or other context script:

nohup service nginx start &

If the process is not wrapped in nohup ... & then it will receive SIGTERM once START_SCRIPT finishes.