We are using Plesk to host our production services.
Basically when I deploy application to Plesk using Git, I need to press Restart application
within Node page on Plesk GUI and that works well.
But in some cases I need to do that pragmatically, I need to automatically restart Node service. Does Plesk offer such functionality? Maybe, some kind of API that listens to calls or else within Linux shell itself.
4
Answers
Since there was no answer for a while, this is my old workaround that I used for PM2 scripts force reset:
If it's a webserver application, e.g. Express.js, add protected route that can be accessed only within your privatae network (for security reasons) which basically kills main process via
process.exit(0)
and your webserver will get reseted automatically by PM2 or whichever service you use for it. However, I wouldn't recommend this method for anything above staging.I have this issue too, and Plesk support don’t have an answer for me either.
According to the Plesk blog here: “Moreover, if your app is running in the “development” mode, you don’t need to restart the app every time you modify the contents of a file.”
I’m very new to Node so I don’t fully understand the implications but I guess if you run the app in development mode, then you won’t need to manually restart the Node Application.
When you click
Restart App
you’ll notice a message stateInformation: The restart.txt file was touched. Application will be restarted after the first request.
You can emulate this action after the deploy by checking
Enable additional deploy actions
in the git repository options, and touching the same file here (I also run npm install too). Screenshot attached.The only way I have found that consistently works on Plesk is this command:
Even in development mode, Node does not seem to automatically restart.
What’s worse is that it takes about 5-6 seconds before Node finishes restarting, using the touch method.
My takeaway is that a Plesk server is the wrong place to do Node development or testing.