From dd3cf08f8b819989336dd3c3a048dbbaa3684b81 Mon Sep 17 00:00:00 2001 From: Unitech Date: Fri, 10 Apr 2020 00:09:13 +0200 Subject: [PATCH] pm2 init changes + chores fixes --- examples/cluster-http/http.js | 2 +- lib/binaries/DevCLI.js | 2 +- lib/binaries/Runtime4Docker.js | 4 ---- lib/templates/ecosystem.tpl | 28 +++++++++------------------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/examples/cluster-http/http.js b/examples/cluster-http/http.js index 912569de6..a31018318 100644 --- a/examples/cluster-http/http.js +++ b/examples/cluster-http/http.js @@ -4,6 +4,6 @@ var http = require('http'); var server = http.createServer(function(req, res) { res.writeHead(200); res.end('hey'); -}).listen(process.env.PORT || 8000, function() { +}).listen(process.env.PORT || 8089, '0.0.0.0', function() { console.log('App listening on port %d', server.address().port); }); diff --git a/lib/binaries/DevCLI.js b/lib/binaries/DevCLI.js index 02f986d9b..b1e2bf79a 100644 --- a/lib/binaries/DevCLI.js +++ b/lib/binaries/DevCLI.js @@ -66,7 +66,7 @@ function run(cmd, opts) { opts.watch = true; opts.autorestart = true; - + opts.restart_delay = 1000 if (opts.autoExit) autoExit(); diff --git a/lib/binaries/Runtime4Docker.js b/lib/binaries/Runtime4Docker.js index 551105c5b..f52f62ce6 100644 --- a/lib/binaries/Runtime4Docker.js +++ b/lib/binaries/Runtime4Docker.js @@ -71,10 +71,6 @@ var Runtime = { }); this.pm2.connect(function(err, pm2_meta) { - if (pm2_meta.new_pm2_instance == false) { - console.warn('[WARN] PM2 Daemon is already running') - } - process.on('SIGINT', function() { Runtime.exit(); }); diff --git a/lib/templates/ecosystem.tpl b/lib/templates/ecosystem.tpl index cf27f3a55..48770eb30 100644 --- a/lib/templates/ecosystem.tpl +++ b/lib/templates/ecosystem.tpl @@ -1,28 +1,18 @@ module.exports = { apps : [{ - name: 'API', - script: 'app.js', - - // Options reference: https://pm2.keymetrics.io/docs/usage/application-declaration/ - args: 'one two', - instances: 1, - autorestart: true, - watch: false, - max_memory_restart: '1G', - env: { - NODE_ENV: 'development' - }, - env_production: { - NODE_ENV: 'production' - } + script: 'index.js', + watch: '.' + }, { + script: './service-worker/', + watch: ['./service-worker'] }], deploy : { production : { - user : 'node', - host : '212.83.163.1', - ref : 'origin/master', - repo : 'git@github.com:repo.git', + user : 'SSH_USERNAME', + host : 'SSH_HOSTMACHINE', + ref : 'GIT_BRANCH', + repo : 'GIT_REPOSITORY', path : '/var/www/production', 'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production' }