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
Support stop msg for daemon node #1018
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
gmarzot
force-pushed
the
support_stop_msg
branch
from
July 20, 2023 16:49
f5e9a34
to
e2b58e9
Compare
|
gmarzot
force-pushed
the
support_stop_msg
branch
from
July 20, 2023 17:27
e2b58e9
to
a06b728
Compare
dceejay
reviewed
Jul 20, 2023
i added the kill on the start msg to trigger a restart, to match documented
behavior..
but equally valid (or more so i guess) would be to change the doc to say
that msg.start only starts (no restart behavior). I can make that change.
eh... debug to cover each message type.. i see no harm as it is off
normally.. your call.
…-G
On Thu, Jul 20, 2023 at 5:13 PM Dave Conway-Jones ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In utility/daemon/daemon.js
<#1018 (comment)>
:
> if (typeof msg.kill !== "string" || msg.kill.length === 0 || !msg.kill.toUpperCase().startsWith("SIG") ) { msg.kill = "SIGINT"; }
node.child.kill(msg.kill.toUpperCase());
}
- else if (msg.hasOwnProperty("start") && !node.running) {
- let args = "";
- if (msg.hasOwnProperty("args") && msg.args.length > 0) {
- args = parseArgs(msg.args.trim());
+ else if (msg.hasOwnProperty("start")) {
+ node.stopped = false;
+ if (!node.running) {
+ let args = "";
+ if (msg.hasOwnProperty("args") && msg.args.length > 0) {
+ args = parseArgs(msg.args.trim());
+ }
+ runit(args);
+ } else {
Why are we doing this here ? If it is called with start and is already
running then we don't want to kill it do we ? Surely just leave it running.
------------------------------
In utility/daemon/daemon.js
<#1018 (comment)>
:
> @@ -32,16 +33,30 @@ module.exports = function(RED) {
function inputlistener(msg) {
if (msg != null) {
- if (msg.hasOwnProperty("kill") && node.running) {
+ if (msg.hasOwnProperty("stop")) {
+ node.stopped = true;
+ if (node.running) {
+ node.child.kill(node.closer);
+ }
+ node.debug(node.cmd+" stopped by msg");
Don't think we need extra debug.
—
Reply to this email directly, view it on GitHub
<#1018 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7T3ICTCHIIJYMMHGAIGBLXRGNOZANCNFSM6AAAAAA2RV4ODM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
one lingering thought is that if someone wants to add new args and trigger
a restart.. the current PR supports that w/ a single msg...
but that can be accomplished with stop then start w/ args.. so i am
continuing to remove the kill i added to msg.start
…On Thu, Jul 20, 2023 at 5:27 PM Giovanni Marzot ***@***.***> wrote:
i added the kill on the start msg to trigger a restart, to match
documented behavior..
but equally valid (or more so i guess) would be to change the doc to say
that msg.start only starts (no restart behavior). I can make that change.
eh... debug to cover each message type.. i see no harm as it is off
normally.. your call.
-G
On Thu, Jul 20, 2023 at 5:13 PM Dave Conway-Jones <
***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In utility/daemon/daemon.js
> <#1018 (comment)>
> :
>
> > if (typeof msg.kill !== "string" || msg.kill.length === 0 || !msg.kill.toUpperCase().startsWith("SIG") ) { msg.kill = "SIGINT"; }
> node.child.kill(msg.kill.toUpperCase());
> }
> - else if (msg.hasOwnProperty("start") && !node.running) {
> - let args = "";
> - if (msg.hasOwnProperty("args") && msg.args.length > 0) {
> - args = parseArgs(msg.args.trim());
> + else if (msg.hasOwnProperty("start")) {
> + node.stopped = false;
> + if (!node.running) {
> + let args = "";
> + if (msg.hasOwnProperty("args") && msg.args.length > 0) {
> + args = parseArgs(msg.args.trim());
> + }
> + runit(args);
> + } else {
>
> Why are we doing this here ? If it is called with start and is already
> running then we don't want to kill it do we ? Surely just leave it running.
> ------------------------------
>
> In utility/daemon/daemon.js
> <#1018 (comment)>
> :
>
> > @@ -32,16 +33,30 @@ module.exports = function(RED) {
>
> function inputlistener(msg) {
> if (msg != null) {
> - if (msg.hasOwnProperty("kill") && node.running) {
> + if (msg.hasOwnProperty("stop")) {
> + node.stopped = true;
> + if (node.running) {
> + node.child.kill(node.closer);
> + }
> + node.debug(node.cmd+" stopped by msg");
>
> Don't think we need extra debug.
>
> —
> Reply to this email directly, view it on GitHub
> <#1018 (review)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AB7T3ICTCHIIJYMMHGAIGBLXRGNOZANCNFSM6AAAAAA2RV4ODM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
dceejay
added a commit
that referenced
this pull request
Aug 5, 2023
Thanks for the PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Types of changes
Proposed changes
This PR adds support to the node-red-node-daemon for a stop message. When stopped the process will be terminated as per the configured signal and will not be restarted by redo until re-set via a subsequent start message.
Documentation updated on start message to indicate it will not restart a running process
grunt
to verify the unit tests pass