// PM2 Config
const path = require('path');
const { name: APP_NAME, repository: REPO } = require('./package.json');

module.exports = {
  apps: [
    {
      name: 'dev-app',
      script: './build/server.dev.js',
      watch: ['./server', './build', './framework'],
      source_map_support: true,

      env: {
        NODE_ENV: 'develop',
      },
    },
    {
      name: `${APP_NAME}-stage`,
      script: './dist/server/bundle.js',
      source_map_support: true,

      env: {
        NODE_ENV: 'stage',
      },
      env_stage: {
        PORT: 7001,
      },
    },
    {
      name: `${APP_NAME}-prod`,
      script: './dist/server/bundle.js',

      env: {
        NODE_ENV: 'prod',
      },
      env_prod: {
        PORT: 9001,
      },
    },
  ],

  deploy: {
    prod: {
      user: 'docker',
      host: 'docker',
      ref: 'origin/master',
      repo: REPO,
      path: path.join('/home/docker', APP_NAME, 'prod'),
      'post-deploy': `yarn; npm run build:prod; pm2 startOrRestart ecosystem.config.js --only ${APP_NAME}-prod --env prod`,

      env: {
        NODE_ENV: 'prod',
      },
    },
    stage: {
      user: 'docker',
      host: 'docker',
      ref: 'origin/dev',
      repo: REPO,
      path: path.join('/home/docker', APP_NAME, 'stage'),
      'post-deploy': `yarn; npm run build:prod; pm2 startOrRestart ecosystem.config.js --only ${APP_NAME}-stage --env stage`,
    },

    env: {
      NODE_ENV: 'stage',
    },
  },
};

@@ -13,20 +13,24 @@
 g%0Aconst 
-path
+%7B join %7D
  = requi
@@ -41,16 +41,18 @@
 path');%0A
+%0A%0A
 const %7B 
@@ -119,249 +119,133 @@
 ');%0A
-%0Amodule.exports = %7B%0A  apps: %5B%0A    %7B%0A      name: 'dev-app',%0A      script: './build/server.dev.js',%0A      watch: %5B'./server', './build', './framework'%5D,%0A      source_map_support: true,%0A%0A      env: %7B%0A        NODE_ENV: 'develop',%0A      %7D,%0A    %7D,
+const serverPath = join('/var/www', APP_NAME);%0Aconst user = 'jumper';%0Aconst host = 'miaooo.me';%0A%0Amodule.exports = %7B%0A  apps: %5B
 %0A   
@@ -358,57 +358,8 @@
 e,%0A%0A
-      env: %7B%0A        NODE_ENV: 'stage',%0A      %7D,%0A
     
@@ -391,12 +391,12 @@
 RT: 
-7
+50
 00
-1
 ,%0A  
@@ -493,56 +493,8 @@
 ',%0A%0A
-      env: %7B%0A        NODE_ENV: 'prod',%0A      %7D,%0A
     
@@ -525,12 +525,12 @@
 RT: 
-9
+60
 00
-1
 ,%0A  
@@ -579,34 +579,24 @@
 %7B%0A      user
-: 'docker'
 ,%0A      host
@@ -591,34 +591,24 @@
 ,%0A      host
-: 'docker'
 ,%0A      ref:
@@ -659,42 +659,23 @@
 th: 
-path.join('/home/docker', APP_NAME
+join(serverPath
 , 'p
@@ -695,36 +695,37 @@
 'post-deploy': %60
-yarn
+npm i
 ; npm run build:
@@ -885,26 +885,16 @@
     user
-: 'docker'
 ,%0A      
@@ -901,18 +901,8 @@
 host
-: 'docker'
 ,%0A  
@@ -958,42 +958,23 @@
 th: 
-path.join('/home/docker', APP_NAME
+join(serverPath
 , 's
@@ -1007,12 +1007,13 @@
 ': %60
-yarn
+npm i
 ; np

optimize ecosystem.config.js