start-stop-daemon always returns '0' although the process fails
I am trying to get an init script running that starts nodejs as a daemon. The problem is, that when I executing start-stop-daemon it always returns '0', regardless of what error the nodejs-daemon may return.
I got as far as figuring out that the issue arises when using start-stop-daemon with the --background switch.
With the switch, start-stop-daemon always returns '0', even when the nodejs-daemon fails.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS ; echo ---error: $?
---error: 0
Note, that the daemon silently failed and is NOT running at this moment!
Without the switch, we can actually see the daemon failing to start.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS ; echo ---error: $?
ERROR: Unsupported version of Node
Ghost needs Node version ~0.10.0 || ~0.12.0 || ^4.2.0 you are using version 5.10.0
Please see http://support.ghost.org/supported-node-versions/ for more information
---error: 231
Now I am looking to find a solution so I can use the --background switch and having a error code bigger than '0' when it fails to start the nodejs daemon.
debian init-script start-stop-daemon
add a comment |
I am trying to get an init script running that starts nodejs as a daemon. The problem is, that when I executing start-stop-daemon it always returns '0', regardless of what error the nodejs-daemon may return.
I got as far as figuring out that the issue arises when using start-stop-daemon with the --background switch.
With the switch, start-stop-daemon always returns '0', even when the nodejs-daemon fails.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS ; echo ---error: $?
---error: 0
Note, that the daemon silently failed and is NOT running at this moment!
Without the switch, we can actually see the daemon failing to start.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS ; echo ---error: $?
ERROR: Unsupported version of Node
Ghost needs Node version ~0.10.0 || ~0.12.0 || ^4.2.0 you are using version 5.10.0
Please see http://support.ghost.org/supported-node-versions/ for more information
---error: 231
Now I am looking to find a solution so I can use the --background switch and having a error code bigger than '0' when it fails to start the nodejs daemon.
debian init-script start-stop-daemon
I am not familiar with nodejs. Can you tell me if thestart-stop-daemonis a script or an LSB executable ? You can runfile $(which start-stop-daemon)to see what type of file it is, if unsure.
– MelBurslan
Apr 5 '16 at 21:17
"/sbin/start-stop-daemon: ELF 64-bit LSB executable […]". That is used in every init-script on Debian, by the way.
– Hurrdurrfurr
Apr 5 '16 at 21:21
Then why don't you first run this command without the--backgroundswitch, sendstdoutto/dev/nullget the error code. If it is zero, the stop it and start it with the--backgroundswitch. Yes it is a convoluted way of doing it but obviously this executable is not handling the error condition properly in background mode. Also you can submit a bug report to the developers of this app.
– MelBurslan
Apr 5 '16 at 21:29
add a comment |
I am trying to get an init script running that starts nodejs as a daemon. The problem is, that when I executing start-stop-daemon it always returns '0', regardless of what error the nodejs-daemon may return.
I got as far as figuring out that the issue arises when using start-stop-daemon with the --background switch.
With the switch, start-stop-daemon always returns '0', even when the nodejs-daemon fails.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS ; echo ---error: $?
---error: 0
Note, that the daemon silently failed and is NOT running at this moment!
Without the switch, we can actually see the daemon failing to start.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS ; echo ---error: $?
ERROR: Unsupported version of Node
Ghost needs Node version ~0.10.0 || ~0.12.0 || ^4.2.0 you are using version 5.10.0
Please see http://support.ghost.org/supported-node-versions/ for more information
---error: 231
Now I am looking to find a solution so I can use the --background switch and having a error code bigger than '0' when it fails to start the nodejs daemon.
debian init-script start-stop-daemon
I am trying to get an init script running that starts nodejs as a daemon. The problem is, that when I executing start-stop-daemon it always returns '0', regardless of what error the nodejs-daemon may return.
I got as far as figuring out that the issue arises when using start-stop-daemon with the --background switch.
With the switch, start-stop-daemon always returns '0', even when the nodejs-daemon fails.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS ; echo ---error: $?
---error: 0
Note, that the daemon silently failed and is NOT running at this moment!
Without the switch, we can actually see the daemon failing to start.
root# start-stop-daemon --start --chuid $GHOST_USER:$GHOST_GROUP --chdir $GHOST_ROOT --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS ; echo ---error: $?
ERROR: Unsupported version of Node
Ghost needs Node version ~0.10.0 || ~0.12.0 || ^4.2.0 you are using version 5.10.0
Please see http://support.ghost.org/supported-node-versions/ for more information
---error: 231
Now I am looking to find a solution so I can use the --background switch and having a error code bigger than '0' when it fails to start the nodejs daemon.
debian init-script start-stop-daemon
debian init-script start-stop-daemon
edited Apr 5 '16 at 21:20
Hurrdurrfurr
asked Apr 5 '16 at 20:56
HurrdurrfurrHurrdurrfurr
252212
252212
I am not familiar with nodejs. Can you tell me if thestart-stop-daemonis a script or an LSB executable ? You can runfile $(which start-stop-daemon)to see what type of file it is, if unsure.
– MelBurslan
Apr 5 '16 at 21:17
"/sbin/start-stop-daemon: ELF 64-bit LSB executable […]". That is used in every init-script on Debian, by the way.
– Hurrdurrfurr
Apr 5 '16 at 21:21
Then why don't you first run this command without the--backgroundswitch, sendstdoutto/dev/nullget the error code. If it is zero, the stop it and start it with the--backgroundswitch. Yes it is a convoluted way of doing it but obviously this executable is not handling the error condition properly in background mode. Also you can submit a bug report to the developers of this app.
– MelBurslan
Apr 5 '16 at 21:29
add a comment |
I am not familiar with nodejs. Can you tell me if thestart-stop-daemonis a script or an LSB executable ? You can runfile $(which start-stop-daemon)to see what type of file it is, if unsure.
– MelBurslan
Apr 5 '16 at 21:17
"/sbin/start-stop-daemon: ELF 64-bit LSB executable […]". That is used in every init-script on Debian, by the way.
– Hurrdurrfurr
Apr 5 '16 at 21:21
Then why don't you first run this command without the--backgroundswitch, sendstdoutto/dev/nullget the error code. If it is zero, the stop it and start it with the--backgroundswitch. Yes it is a convoluted way of doing it but obviously this executable is not handling the error condition properly in background mode. Also you can submit a bug report to the developers of this app.
– MelBurslan
Apr 5 '16 at 21:29
I am not familiar with nodejs. Can you tell me if the
start-stop-daemon is a script or an LSB executable ? You can run file $(which start-stop-daemon) to see what type of file it is, if unsure.– MelBurslan
Apr 5 '16 at 21:17
I am not familiar with nodejs. Can you tell me if the
start-stop-daemon is a script or an LSB executable ? You can run file $(which start-stop-daemon) to see what type of file it is, if unsure.– MelBurslan
Apr 5 '16 at 21:17
"/sbin/start-stop-daemon: ELF 64-bit LSB executable […]". That is used in every init-script on Debian, by the way.
– Hurrdurrfurr
Apr 5 '16 at 21:21
"/sbin/start-stop-daemon: ELF 64-bit LSB executable […]". That is used in every init-script on Debian, by the way.
– Hurrdurrfurr
Apr 5 '16 at 21:21
Then why don't you first run this command without the
--background switch, send stdout to /dev/null get the error code. If it is zero, the stop it and start it with the --background switch. Yes it is a convoluted way of doing it but obviously this executable is not handling the error condition properly in background mode. Also you can submit a bug report to the developers of this app.– MelBurslan
Apr 5 '16 at 21:29
Then why don't you first run this command without the
--background switch, send stdout to /dev/null get the error code. If it is zero, the stop it and start it with the --background switch. Yes it is a convoluted way of doing it but obviously this executable is not handling the error condition properly in background mode. Also you can submit a bug report to the developers of this app.– MelBurslan
Apr 5 '16 at 21:29
add a comment |
2 Answers
2
active
oldest
votes
This is documented behavior. The foreground process completes after forking the background process. From the man page:
-b, --background
Typically used with programs that don't detach on their own. This option will force start-stop-daemon to fork before starting the process, and force
it into the background. Warning: start-stop-daemon cannot check the exit status if the process fails to execute for any reason. This is a last
resort, and is only meant for programs that either make no sense forking on their own, or where it's not feasible to add the code for them to do this
themselves.
add a comment |
we found that after a file system issue some of the mongo files ended up being owned by root. For this particular issue it was the journal files. Change all of these back to mongodb:mongodb with chown mongodb:mongodb * in the db/journal directory. Also important to delete the mongod.lock file in the db directory. What was also a little wierd was that removing the --background option in the start_stop_deamon worked but of course you want it to run in the background
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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%2f274541%2fstart-stop-daemon-always-returns-0-although-the-process-fails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is documented behavior. The foreground process completes after forking the background process. From the man page:
-b, --background
Typically used with programs that don't detach on their own. This option will force start-stop-daemon to fork before starting the process, and force
it into the background. Warning: start-stop-daemon cannot check the exit status if the process fails to execute for any reason. This is a last
resort, and is only meant for programs that either make no sense forking on their own, or where it's not feasible to add the code for them to do this
themselves.
add a comment |
This is documented behavior. The foreground process completes after forking the background process. From the man page:
-b, --background
Typically used with programs that don't detach on their own. This option will force start-stop-daemon to fork before starting the process, and force
it into the background. Warning: start-stop-daemon cannot check the exit status if the process fails to execute for any reason. This is a last
resort, and is only meant for programs that either make no sense forking on their own, or where it's not feasible to add the code for them to do this
themselves.
add a comment |
This is documented behavior. The foreground process completes after forking the background process. From the man page:
-b, --background
Typically used with programs that don't detach on their own. This option will force start-stop-daemon to fork before starting the process, and force
it into the background. Warning: start-stop-daemon cannot check the exit status if the process fails to execute for any reason. This is a last
resort, and is only meant for programs that either make no sense forking on their own, or where it's not feasible to add the code for them to do this
themselves.
This is documented behavior. The foreground process completes after forking the background process. From the man page:
-b, --background
Typically used with programs that don't detach on their own. This option will force start-stop-daemon to fork before starting the process, and force
it into the background. Warning: start-stop-daemon cannot check the exit status if the process fails to execute for any reason. This is a last
resort, and is only meant for programs that either make no sense forking on their own, or where it's not feasible to add the code for them to do this
themselves.
answered Apr 5 '16 at 22:38
BillThorBillThor
7,7031425
7,7031425
add a comment |
add a comment |
we found that after a file system issue some of the mongo files ended up being owned by root. For this particular issue it was the journal files. Change all of these back to mongodb:mongodb with chown mongodb:mongodb * in the db/journal directory. Also important to delete the mongod.lock file in the db directory. What was also a little wierd was that removing the --background option in the start_stop_deamon worked but of course you want it to run in the background
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
we found that after a file system issue some of the mongo files ended up being owned by root. For this particular issue it was the journal files. Change all of these back to mongodb:mongodb with chown mongodb:mongodb * in the db/journal directory. Also important to delete the mongod.lock file in the db directory. What was also a little wierd was that removing the --background option in the start_stop_deamon worked but of course you want it to run in the background
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
we found that after a file system issue some of the mongo files ended up being owned by root. For this particular issue it was the journal files. Change all of these back to mongodb:mongodb with chown mongodb:mongodb * in the db/journal directory. Also important to delete the mongod.lock file in the db directory. What was also a little wierd was that removing the --background option in the start_stop_deamon worked but of course you want it to run in the background
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
we found that after a file system issue some of the mongo files ended up being owned by root. For this particular issue it was the journal files. Change all of these back to mongodb:mongodb with chown mongodb:mongodb * in the db/journal directory. Also important to delete the mongod.lock file in the db directory. What was also a little wierd was that removing the --background option in the start_stop_deamon worked but of course you want it to run in the background
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 16 mins ago
SkippySkippy
1
1
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Skippy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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.
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%2f274541%2fstart-stop-daemon-always-returns-0-although-the-process-fails%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
I am not familiar with nodejs. Can you tell me if the
start-stop-daemonis a script or an LSB executable ? You can runfile $(which start-stop-daemon)to see what type of file it is, if unsure.– MelBurslan
Apr 5 '16 at 21:17
"/sbin/start-stop-daemon: ELF 64-bit LSB executable […]". That is used in every init-script on Debian, by the way.
– Hurrdurrfurr
Apr 5 '16 at 21:21
Then why don't you first run this command without the
--backgroundswitch, sendstdoutto/dev/nullget the error code. If it is zero, the stop it and start it with the--backgroundswitch. Yes it is a convoluted way of doing it but obviously this executable is not handling the error condition properly in background mode. Also you can submit a bug report to the developers of this app.– MelBurslan
Apr 5 '16 at 21:29