-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nmmain
self-daemonizing is memory inefficient
#117
Comments
This was referenced Jun 17, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unless instructed otherwise via the
--foreground
command-line flag, the nodemanager automatically daemonizes after starting up. This puts it in the background and decouples it from the controlling terminal (if any). (Otherwise, runningstart_seattle.sh
orpython nmmain.py
and later closing the terminal would kill the nodemanager.)In order to daemonize, the nodemanager
fork()
s twice and redirects its stdstreams from / to/dev/null
effectively. Only the latter of the forked children is kept alive, the parent and first child processes both exit.On systems with small amounts of available memory such as WiFi routers running OpenWrt,
fork()
ing is problematic: The parent nodemanager process consumes significant amounts of RAM already, and RAM consuption increases linearly with every fork as a copy of the parent process' memory image is created. Due to the typically low CPU speed of these devices, this transient spike in RAM consumption can lock up the system for minutes, or even cause memory exhaustion which crashes the nodemanager.An immediate solution would be to not self-daemonize, but rather use common POSIX tools to achieve the same thing:
(
nohup
disables signal forwarding from the terminal to the process, the<
,>
redirectstdin
andstdout
so that the process doesn't read from or write to the terminal anymore,2>&1
redirectsstderr
into the already-redirectedstdout
, and&
puts the whole thing in the background).This snippet would render self-daemonizing in
nmmain.py
unneccessary, and would replace backgrounding without detaching in the Seattle start shell script.The text was updated successfully, but these errors were encountered: