0

I have created a script that can run the python django application. I run this script using pm2. I do pm2 start scripts.sh, it works properly but after some time my application doesn't work and displays an error like this

the runtime process for the instance running on port 37001 has unexpectedly quit**

I show the log using pm2 logs, it displays an error like this

script.sh had too many unstable restarts (16). Stopped. "errored"

How to resolved it? Can anyone help me?

Vladislav Povorozniuc
  • 2,149
  • 25
  • 26
Keyur Patel
  • 89
  • 4
  • 9

2 Answers2

0

Primarily I have created a configuration file using the following command:

cd ~
pm2 init
sudo nano ecosystem.config.js

Then copy and paste the following code into the newly created ecosystem.config.js file (note: change your project location in cwd section):

apps: [
    {
        name: 'my-site',
        cwd: ' /home/your-name/your-project-directory',
        script: 'npm',
        args: 'start',
        env: {
              NODE_PUBLIC_APP: 'NODE_PUBLIC_APP', // for example
        },
   },
   // optionally a second project
],};

After that before running the app using pm2 I did the following:

pm2 kill
sudo rm -rf node_modules
npm i

Then I run the application in watch mode, so that I can see what is going on using pm2 log later. To run the app in watch mode do the following:

pm2 start npm --name "AnyAppName" -- run start --watch

And finally I see the logs what causes the error by running the following command:

pm2 log

Hope this helps someone in the future like me.

Siddiqui Noor
  • 5,575
  • 5
  • 25
  • 41
-2

I had the same issue and resolved with: pm2 kill rm -rf node_modules npm i pm2 start index.js

sudo shutdown -r now