yarn add pm2
scripts.start
to use pm2 start...
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "pm2 start ./node_modules/nuxt/bin/nuxt-start -i max --attach",
"generate": "nuxt generate",
"serverbuild": "nuxt build",
"lint": "eslint --ext .js,.vue --ignore-path .eslintignore .",
"precommit": "npm run lint"
},
...
Just another way of doing it ;-)
npm i -g pm2
pm2 start npm --name "your-app-alias" -- start
pm2 restart your-app-alias
@NicoPennec where would we mix a yarn generate
in this? before the restart?
@acidjazz yes, you can run the generate cmd before the restart.
But yarn generate
is for static server!
PM2 is for dynamic server (nodejs).
You can use PM2 has static server, but it's not the main purpose.
@NicoPennec well static server or not you need to nuxt generate, and if you have dynamic routes you cant you need to still serve /dist/
with nuxt for the router right?
Or maybe I'm confusing generate with build?
@NicoPennec When you run through pm2
using npm
~javscript
pm2 start npm --name "your-app-alias" -- start
~
could specify options ? (typically PORT
)
I finally could make it work on Windows (with ecosystem file, npm scripts and environment variables), check out the gist:
https://gist.github.com/gangsthub/a6862362cd49a9d2ed710dc72997c87a
Hi @gangsthub ,
Thanks for update. I've personally added in my package.json
"scripts": {
"prod": "pm2 start npm ecosystem.config.js --name nuxt -- start"
}
so I can run npm run prod
and ecosystem.config.js
is
module.exports = {
apps : [
{
name: "nuxt",
script: "./node_modules/nuxt/bin/nuxt-start",
env: {
"HOST": "0.0.0.0",
"PORT": 80,
"NODE_ENV": "production",
}
}
]
}
What is basically quite the same as you do.
:heart:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Just another way of doing it ;-)
npm i -g pm2
pm2 start npm --name "your-app-alias" -- start
pm2 restart your-app-alias