Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

how to terminate node process #1172

Closed
craigcosmo opened this issue Jun 12, 2011 · 7 comments
Closed

how to terminate node process #1172

craigcosmo opened this issue Jun 12, 2011 · 7 comments

Comments

@craigcosmo
Copy link

I run node server.js in the terminal, then terminal hung, I had to quit terminal.

When I opened the terminal back. I tried to load server.js again, it says add already in use. And the app is still running.

Now I had made some change with server.js, I want to stop the current server, and reload it so the new changes will apply.

How can I terminate the current server.js ?

@murvinlai
Copy link

you have to check Linux process.
% ps -A

then, let say the node process id is 12345
then just do that:

% kill 12345 or kill -9 12345

The reason u can't start the server again because it is using the same port.

@bradwright
Copy link

An easier way to find this:

ps -ef | grep node

should show you all processes matching node. To kill without knowing the PID (will also kill any other processes matching node):

pkill -f node

@dresende
Copy link

You could listen for SIGUSR1 or SIGUSR2 signals and terminate the process correctly.

process.on("SIGUSR1", function () {
    // stop stuff
    server.end();
    // ...
    // end process
    process.exit(0);
});

You can send the signal with:

kill -USR1 process_id

@bnoordhuis
Copy link
Member

Not a bug but seems to have been resolved anyway. :)

@nakamuraagatha
Copy link

nakamuraagatha commented Jul 13, 2016

How to start again node after pkill node?

i use this command on ssh

pkill node

and i don't know about start again that node

@eljefedelrodeodeljefe
Copy link

@fatimazbouj this is a PHP questions. Please refer to the PHP docs. Probably something like http://php.net/manual/de/function.proc-get-status.php

@bnoordhuis
Copy link
Member

This bug tracker is not the right place for support questions, try https://github.com/nodejs/help/issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants