PM2 로그 경로 설정 명령어

sudo pm2 start --name test -o /data/test/test.log -e /data/test/test_error.log app.js

하지만 로그 경로가 바뀌거나 하면, 다시 명령어를 쳐야 하는 문제가 존재합니다.

 

아래와 같이 설정파일을 생성하면 쉽게 관리가 가능합니다.

ecosystem.config.js

module.exports = {
  apps : [{
    name: 'test',
    script: './test/app.js',
    instances: 1,
    exec_mode: "cluster",
    autorestart: true,
    watch: false,
    output:"/data/test/test-out.log",
    error:"/data/test/test-error.log",
    env_production: {
      NODE_ENV: "production",
    }
  }],

  config : {
	days_interval : 2,
        max_size : 10
  },

  deploy : {
    production : {
      user : 'SSH_USERNAME',
      host : 'SSH_HOSTMACHINE',
      ref  : 'origin/master',
      repo : 'GIT_REPOSITORY',
      path : 'DESTINATION_PATH',
      'pre-deploy-local': '',
      'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production',
      'pre-setup': ''
    }
  }
};

 

위와 같이 파일을 만들고 해당 경로에서 아래와 같이 PM2를 실행하면 됩니다.

sudo pm2 start --only test

 

+ Recent posts