I've been following the official docs for deploying a Strapi app onto Digital ocean, but I'm having trouble setting up pm2. It starts the app for a second, and then shows
status: errored
there's no script.js to run the app, but when I cd to /home/myusername/appname/backend and run npm start, it works just fine, which leads me to believe that I have the ENV variables set correctly
Here's the config file
module.exports = {
apps: [
{
name: 'strapi',
cwd: '/home/your-name/project/backend',
script: 'npm',
args: 'start',
env: {
NODE_ENV: 'production',
DATABASE_HOST: 'localhost', // database endpoint
DATABASE_PORT: '5432',
DATABASE_NAME: 'strapi', // DB name
DATABASE_USERNAME: 'your-name', // your username for psql
DATABASE_PASSWORD: 'password', // your password for psql
},
},
],
};
Then I run pm2 logs, I see
2020-07-13T01:58:49: PM2 log: App [strapi:0] online
PM2 | 2020-07-13T01:58:49: PM2 error: Error: spawn node ENOENT
PM2 | at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
PM2 | at onErrorNT (internal/child_process.js:415:16)
PM2 | at process._tickCallback (internal/process/next_tick.js:63:19)
Thanks
Strapi can be deployed on traditional hosting servers or services such as 21YunBox, Render, Heroku, AWS, Azure and others.
Install Strapi Locally. Push your Strapi codebase to Github. Connect your Heroku account to your Github(the project repository) and enable Automatic Deploy. Connect your Strapi project to Postgres add-on database provided by Heroku.
NODE_ENV: 'production',
DATABASE_HOST: '127.0.0.1', // database endpoint
DATABASE_PORT: '5432',
DATABASE_NAME: 'THE DB NAME EX.SAMMY'
DATABASE_USERNAME: 'THE DB USERNAME EX.SAMMY'
DATABASE_PASSWORD: 'THE DB PASSWORD'
pm2 del 0 (check strapi app with pm2 start)
pm2 start ecosystem.config.js
for me it was because cwd
was already relative and didn't like how my path was structured. I tried ~/my-app
as well as /home/me/my-app
and both were wrong. It eventually just wanted my-app
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With