Why “start-stop-daemon” spawns two processes?
Clash Royale CLAN TAG#URR8PPP
Here is a piece of my SysVinit file.
NAME="flask-daemon"
PIDFILE="/var/run/"$NAME".pid"
DAEMON="/home/ubuntu/flask/run.py"
DAEMON_USER=root
f_start()
echo -e "nStarting : $NAME"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --exec $DAEMON
Does anyone knows where must be the error?
Also, it's terrible that in this situation, it is only writing the PID of ONE process into the pidfile. Therefore, if I do /etc/init.d/flask-daemon stop
, it only kills the process which is related with the PID that was considered to be written into the file.
Processes (Why two?):
ps aux | grep run.py
root 3591 3.0 1.7 132700 17460 ? S 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3595 4.5 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3602 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
PID file:
$ cat /var/run/flask-daemon.pid
3591
Just one process was killed...
ps aux | grep run.py
root 3595 0.3 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3613 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
Observation:> I also tried to use --startas
, but it spawns two processes as well, an even worst: it records the PID from any other process into /var/run/flask-daemon.py
, with exception of the PIDs from the daemons
sysvinit start-stop-daemon
add a comment |
Here is a piece of my SysVinit file.
NAME="flask-daemon"
PIDFILE="/var/run/"$NAME".pid"
DAEMON="/home/ubuntu/flask/run.py"
DAEMON_USER=root
f_start()
echo -e "nStarting : $NAME"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --exec $DAEMON
Does anyone knows where must be the error?
Also, it's terrible that in this situation, it is only writing the PID of ONE process into the pidfile. Therefore, if I do /etc/init.d/flask-daemon stop
, it only kills the process which is related with the PID that was considered to be written into the file.
Processes (Why two?):
ps aux | grep run.py
root 3591 3.0 1.7 132700 17460 ? S 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3595 4.5 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3602 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
PID file:
$ cat /var/run/flask-daemon.pid
3591
Just one process was killed...
ps aux | grep run.py
root 3595 0.3 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3613 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
Observation:> I also tried to use --startas
, but it spawns two processes as well, an even worst: it records the PID from any other process into /var/run/flask-daemon.py
, with exception of the PIDs from the daemons
sysvinit start-stop-daemon
add a comment |
Here is a piece of my SysVinit file.
NAME="flask-daemon"
PIDFILE="/var/run/"$NAME".pid"
DAEMON="/home/ubuntu/flask/run.py"
DAEMON_USER=root
f_start()
echo -e "nStarting : $NAME"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --exec $DAEMON
Does anyone knows where must be the error?
Also, it's terrible that in this situation, it is only writing the PID of ONE process into the pidfile. Therefore, if I do /etc/init.d/flask-daemon stop
, it only kills the process which is related with the PID that was considered to be written into the file.
Processes (Why two?):
ps aux | grep run.py
root 3591 3.0 1.7 132700 17460 ? S 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3595 4.5 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3602 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
PID file:
$ cat /var/run/flask-daemon.pid
3591
Just one process was killed...
ps aux | grep run.py
root 3595 0.3 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3613 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
Observation:> I also tried to use --startas
, but it spawns two processes as well, an even worst: it records the PID from any other process into /var/run/flask-daemon.py
, with exception of the PIDs from the daemons
sysvinit start-stop-daemon
Here is a piece of my SysVinit file.
NAME="flask-daemon"
PIDFILE="/var/run/"$NAME".pid"
DAEMON="/home/ubuntu/flask/run.py"
DAEMON_USER=root
f_start()
echo -e "nStarting : $NAME"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --exec $DAEMON
Does anyone knows where must be the error?
Also, it's terrible that in this situation, it is only writing the PID of ONE process into the pidfile. Therefore, if I do /etc/init.d/flask-daemon stop
, it only kills the process which is related with the PID that was considered to be written into the file.
Processes (Why two?):
ps aux | grep run.py
root 3591 3.0 1.7 132700 17460 ? S 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3595 4.5 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3602 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
PID file:
$ cat /var/run/flask-daemon.pid
3591
Just one process was killed...
ps aux | grep run.py
root 3595 0.3 1.7 213144 18080 ? Sl 19:27 0:00 /usr/bin/python /home/ubuntu/flask/run.py
root 3613 0.0 0.0 10460 948 pts/0 S+ 19:27 0:00 grep --color=auto run.py
Observation:> I also tried to use --startas
, but it spawns two processes as well, an even worst: it records the PID from any other process into /var/run/flask-daemon.py
, with exception of the PIDs from the daemons
sysvinit start-stop-daemon
sysvinit start-stop-daemon
edited Dec 20 '18 at 7:22
Rui F Ribeiro
39k1479130
39k1479130
asked Jun 9 '16 at 20:16
ivanleoncz
185110
185110
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Guessing you're daemon is running in daemon mode, so it's creating a copy of itself when it starts.
I think that might be what the "l" part of "Sl" means in the STAT column of your ps output.
I've been use python-daemon quite a bit recently and if that's what your script is using, you can tell it whether to detach the process or not in the constructor of your daemoncontext, just tell it not to do that and you should be golden.
-OR-
don't use start-stop-daemon and just make a systemd service that utilizes the detach_process flag.
-OR-
Do both and tell your process whether you want to detach the process or not.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f288798%2fwhy-start-stop-daemon-spawns-two-processes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Guessing you're daemon is running in daemon mode, so it's creating a copy of itself when it starts.
I think that might be what the "l" part of "Sl" means in the STAT column of your ps output.
I've been use python-daemon quite a bit recently and if that's what your script is using, you can tell it whether to detach the process or not in the constructor of your daemoncontext, just tell it not to do that and you should be golden.
-OR-
don't use start-stop-daemon and just make a systemd service that utilizes the detach_process flag.
-OR-
Do both and tell your process whether you want to detach the process or not.
add a comment |
Guessing you're daemon is running in daemon mode, so it's creating a copy of itself when it starts.
I think that might be what the "l" part of "Sl" means in the STAT column of your ps output.
I've been use python-daemon quite a bit recently and if that's what your script is using, you can tell it whether to detach the process or not in the constructor of your daemoncontext, just tell it not to do that and you should be golden.
-OR-
don't use start-stop-daemon and just make a systemd service that utilizes the detach_process flag.
-OR-
Do both and tell your process whether you want to detach the process or not.
add a comment |
Guessing you're daemon is running in daemon mode, so it's creating a copy of itself when it starts.
I think that might be what the "l" part of "Sl" means in the STAT column of your ps output.
I've been use python-daemon quite a bit recently and if that's what your script is using, you can tell it whether to detach the process or not in the constructor of your daemoncontext, just tell it not to do that and you should be golden.
-OR-
don't use start-stop-daemon and just make a systemd service that utilizes the detach_process flag.
-OR-
Do both and tell your process whether you want to detach the process or not.
Guessing you're daemon is running in daemon mode, so it's creating a copy of itself when it starts.
I think that might be what the "l" part of "Sl" means in the STAT column of your ps output.
I've been use python-daemon quite a bit recently and if that's what your script is using, you can tell it whether to detach the process or not in the constructor of your daemoncontext, just tell it not to do that and you should be golden.
-OR-
don't use start-stop-daemon and just make a systemd service that utilizes the detach_process flag.
-OR-
Do both and tell your process whether you want to detach the process or not.
answered Jun 9 '16 at 21:21
Peter Turner
5631825
5631825
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f288798%2fwhy-start-stop-daemon-spawns-two-processes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown