mirror of
https://github.com/strapi/strapi.git
synced 2025-10-18 03:23:49 +00:00
Add section on pm2 because it is a very common usecase
This commit is contained in:
parent
3419e4570c
commit
cdf5f2c5aa
@ -654,10 +654,68 @@ Finally if you want to run your project in different envrionments use `NODE_ENV=
|
||||
|
||||
## Updating Deployments
|
||||
|
||||
When deploying a Strapi project you will have to make sure the `build` script is ran. (e.g `npm run build`)
|
||||
### Building your admin panel
|
||||
|
||||
If you are deploying your Strapi project with the Admin panel together, you will have to make sure the `build` script runs before running the project. (e.g `npm run build`)
|
||||
|
||||
Depending on your deployment environment you might have to run the `build` script with `NODE_ENV=production npm run build` if the envrionment doesn't include it by default.
|
||||
|
||||
For example `heroku` will automatically run the `build` script for you and set `NODE_ENV=production` before running the scripts so you won't have to think about it.
|
||||
|
||||
### Running the project
|
||||
|
||||
Previously you could run your project by running `node server.js`. As we remove the `server.js` file you will have to either run `npm run start` or create a `server.js` file (read more [here](#migrating-server.js))
|
||||
|
||||
#### PM2
|
||||
|
||||
if you are using pm2 to run your application in production you can update your script like so
|
||||
|
||||
**Before**
|
||||
|
||||
```bash
|
||||
NODE_ENV=production pm2 start server.js
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```bash
|
||||
NODE_ENV=production pm2 start npm -- start
|
||||
```
|
||||
|
||||
If you are using an `ecosystem.config.js` you can do the following
|
||||
|
||||
**Before**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'your-app-name',
|
||||
script: '.path-to/your-strapi-app/server.js',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'your-app-name',
|
||||
cwd: '.path-to/your-strapi-app',
|
||||
script: 'npm',
|
||||
args: 'start',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
12
examples/getstarted/ecosystem.config.js
Normal file
12
examples/getstarted/ecosystem.config.js
Normal file
@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: 'strapi-getstarted',
|
||||
script: 'npm',
|
||||
args: 'start',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user