start Directus with Pm2 as Service , PM2 Error C:\PROGRAM ILES\NODEJS\NPM.CMD:1| :: Created by npm, please don’t edit manually.| ^start Directus with Pm2 as Service , How to start directus using pm2?Error


It may help others to run directus as background service.

npm install pm2 -g

Make it as environment variable

https://dev.to/gortron/environment-variables-with-pm2-the-right-way-42ij

create service.js ins the same folder of directus package.json and add below.

const exec = require(‘child_process’).exec;

const path = require(‘path’);

const client = exec(‘npm run start’,

{ windowsHide: true, cwd: path.join(__dirname, ‘./’), });

client.stdout.pipe(process.stdout); client.stderr.pipe(process.stderr);

pm2 start service.js

npx pm2 start service.js -f

If your pm2 process stop on logof use below command.

npx pm2 update

Leave a comment