mirror of
https://github.com/EvolutionAPI/evolution-manager.git
synced 2025-12-19 19:42:19 -06:00
feat: cli v0.2.0
This commit is contained in:
34
lib/pm2/setup.js
Normal file
34
lib/pm2/setup.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const build = require('../utils/build.js');
|
||||
const verifyPm2Installation = require('../utils/verifyPm2Installation.js');
|
||||
const detectPm2ProcessId = require('../utils/detectPm2ProcessId.js');
|
||||
const { exec } = require('child_process')
|
||||
|
||||
module.exports = async (argv) => {
|
||||
const port = argv.port || 9615;
|
||||
|
||||
await verifyPm2Installation(true);
|
||||
await build();
|
||||
|
||||
const pm2ProcessId = await detectPm2ProcessId();
|
||||
|
||||
if (pm2ProcessId !== false) {
|
||||
console.log('📦 Manager process already setup')
|
||||
await require('./reset.js')(argv, pm2ProcessId);
|
||||
return
|
||||
}
|
||||
|
||||
console.log('⚙️ Starting PM2 process')
|
||||
console.time('⚙️ Starting PM2 process')
|
||||
exec(`pm2 serve dist/ ${port} --name evolution-manager --spa`, (err, stdout) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
console.log(stdout)
|
||||
console.timeEnd('⚙️ Starting PM2 process')
|
||||
|
||||
console.log('🚀 PM2 process started')
|
||||
console.log('🚀 Manager ready in port :' + port)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user