I have several projects inside a Digital Ocean Droplet proxied with nginx and i want to start all of them with pm2, i saw i can achieve that with a .json file with the names and scripts inside, but it doesn't seem to be working, this is what i did:
My droplet directory with the projects:
project1
project2
pm2-apps.json
pm2-apps.json
{
"apps": [
{
"name": "project1",
"script": "./project1/package.json"
},
{
"name": "project2",
"script": "./project2/package.json"
},
]
}
then i run
pm2 start pm2-apps.json
and i get
but then i enter the url, the project doesnt seem to be correctly mounted, if i run each one apart with pm2 start npm -- start
inside the project folder, it works.
Had to test this, and found a couple of issue you might be having, presuming you have nginx is correctly setup.
I had to change the file to the following:
{
"apps": [
{
"name": "project1",
"cwd": "./project1",
"script": "/usr/bin/npm",
"args": "run dev"
},
{
"name": "project2",
"cwd": "./project2",
"script": "/usr/bin/npm",
"args": "run dev"
}
]
}
oddly "script": "npm",
was not enough as was SIGINT'ing which I could see from using pm2 monit
then in each of the projects, I changed the nuxt port:
nuxt.config.js
...
server: {
port: 3001, // project1
host: '0.0.0.0', // default: localhost
},
...
and
...
server: {
port: 3002, // project2
host: '0.0.0.0', // default: localhost
},
...
then clear out pm2.. pm2 delete all
then run from within the folder:
pm2 start pm2-apps.json
Both apps then start without issue..