Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

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

Closed
ospalax opened this issue May 6, 2022 · 1 comment
Closed

Comments

@ospalax
Copy link

ospalax commented May 6, 2022

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 ospalax self-assigned this May 6, 2022
ospalax pushed a commit to ospalax/addon-context-linux that referenced this issue May 31, 2022
Scripts run by one-contexd will not be executed in a subshell - this
will fix the issue with the START_SCRIPT which would hold the boot if
any long-running process would originate in it (e.g. daemon/service).

User still will need to do something like this inside the START_SCRIPT
(or any other context script) otherwise SIGTERM will be sent:

    nohup service nginx start &

Signed-off-by: Petr Ospalý <[email protected]>
ospalax pushed a commit that referenced this issue May 31, 2022
@ospalax
Copy link
Author

ospalax commented May 31, 2022

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.

@ospalax ospalax closed this as completed May 31, 2022
@dann1 dann1 added this to the 6.4.1 milestone Jun 21, 2022
rsmontero pushed a commit that referenced this issue Apr 26, 2023
Scripts run by one-contexd will not be executed in a subshell - this
will fix the issue with the START_SCRIPT which would hold the boot if
any long-running process would originate in it (e.g. daemon/service).

User still will need to do something like this inside the START_SCRIPT
(or any other context script) otherwise SIGTERM will be sent:

    nohup service nginx start &

Signed-off-by: Petr Ospalý <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants