I have a node script in which I need to stop a forever process, before uploading the new version and restart it again;
the problem is that I only know the name of that process, and
forever stop processName.js
doesn't work, since it expect the index or the uid; is it possible to stop it knowing only the name?
What is forever? Forever is an npm module that ensures a Node. js script continuously runs in the background on the server. It's a helpful CLI tool for the production environment because it helps manage the Node applications and their processes.
To start running a script with forever, use the forever start command, followed by the script name. You can run as many scripts as you need using forever . To check if there's any running forever process, run the forever list command. The forever process will be registered and keep running in the background.
Finally I got it, using a variable:
uid=$(forever list | grep processName.js | cut -c24-27) && forever stop $uid
forever stop /home/user/server/script.js (full path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With