'cron_restart'에 해당되는 글 1건

  1. 2020.09.29 JSON 파일로 여러 node 동시 실행 및 자동 재실행 파일 만들기
html52020. 9. 29. 10:50

# JSON 파일로 여러 node 동시 실행 방법

 

(1) 서버에 PM2 설치 : npm install pm2

(2) json 파일 생성하기 : play.json

{

  "apps":

  [

    {

      "name""play_1",

      "script""js/play_1.js",

      "watch"false,

      "env": {

        "NODE_ENV""production",

        "API_PORT"7000

      },

      "autorestart"true,

      "restart_delay":2000,

      "node_args": ["--max_old_space_size=4096"]

    },

    {

      "name""play_2",

      "script""js/play_2.js",

      "watch"false,

      "env": {

        "NODE_ENV""production",

        "API_PORT"7000

      },

      "autorestart"true,

      "restart_delay":2000,

      "node_args": ["--max_old_space_size=4096"]

    }

]}

 

(3) 실행 : pm2 start play.json

 

# node 특정 시간 자동 재실행

 

  (1) 사용 방법 : 위의 json 파일 생성하여 일괄 실행 파일 에  "cron_restart""0 6 * * 1" 추가

    {

      "name""play_0",

      "script""js/play_0.js",

      "watch"false,

      "env": {

        "NODE_ENV""production",

        "API_PORT"5000

      },

      "cron_restart""0 6 * * 1",

      "autorestart"true,

      "restart_delay":2000,

      "node_args": ["--max_old_space_size=4096"]

    }

 

(2) 시간 설정

-  "cron_restart""0 6 * * 1", <=== 월요일 마다  6 시 0분에 재실행

- 값 순서 : 분(0~59) , 시간(0~23), 일(1~31), 월(1~12), 요일(0~7)

 

Posted by 차돌이라네