Skip to content
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

[feat]: Enable restarting node process manually while using --watch option #50212

Closed
pacifiquem opened this issue Oct 17, 2023 · 6 comments
Closed
Labels
feature request Issues that request new features to be added to Node.js. stale

Comments

@pacifiquem
Copy link

pacifiquem commented Oct 17, 2023

What is the problem this feature will solve?

This will enable manual restart while using --watch option even if there was no change in the codebase.

What is the feature you are proposing to solve the problem?

The --watch option in Node.js tells Node.js to watch for changes to the specified file or directory and restart the Node.js process when any changes are detected. This is useful for development, as it allows you to make changes to your code and see the results immediately without having to manually restart the Node.js process.

But what if I want to manually restart the Node.js process? how I'm I going to do that?
That's how I'm requesting to add a command that can do that for us. like: nodemon have rs

see: npmjs.com/package//nodemon#manual-restarting for more info.

What alternatives have you considered?


@pacifiquem pacifiquem added the feature request Issues that request new features to be added to Node.js. label Oct 17, 2023
@bnoordhuis
Copy link
Member

Too vague to be actionable. What kind of server and how should it be refreshed. Be specific.

@marco-ippolito
Copy link
Member

marco-ippolito commented Oct 17, 2023

do you mean this feature of nodemon? https://www.npmjs.com/package//nodemon#manual-restarting

Manual restarting
Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restart nodemon, you can type rs with a carriage return, and nodemon will restart your process.

@pacifiquem
Copy link
Author

Manual restarting.
like this feature of nodemon: npmjs.com/package//nodemon#manual-restarting

@pacifiquem pacifiquem changed the title [feat]: Enable refreshing server while using --watch [feat]: Enable restarting node process manually using --watch option Oct 17, 2023
@pacifiquem pacifiquem changed the title [feat]: Enable restarting node process manually using --watch option [feat]: Enable restarting node process manually while using --watch option Oct 18, 2023
@debadree25
Copy link
Member

I tried exploring this a little, it seems the feature would be pretty simple implement something like

function customInstructionHandler(data) {
  if (data.toString() === 'rs\n') {
    restart();
  }
}

// Exiting gracefully to avoid stdout/stderr getting written after
// parent process is killed.
// this is fairly safe since user code cannot run in this process
function signalHandler(signal) {
  return async () => {
    console.log('signalHandler');
    process.stdin.removeAllListeners();
    watcher.clear();
    const exitCode = await killAndWait(signal, true);
    console.log('exitCode', exitCode);
    console.log('doing process.exit');
    process.exit(exitCode ?? kNoFailure);
  };
}

process.on('SIGTERM', signalHandler('SIGTERM'));
process.on('SIGINT', signalHandler('SIGINT'));
process.stdin.on('data', customInstructionHandler);

but the main issue is somehow this blocks exiting the process even doing something like CtrlC keeps the process running no idea why this happens but if anyone here might have any insight into this would be grateful!

Copy link
Contributor

There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale Mark issue so that it is never considered stale label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Jun 18, 2024
Copy link
Contributor

There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. stale
Projects
None yet
Development

No branches or pull requests

4 participants