Programming
Node js 의 앱을 우분투 부팅시 실행하기
woody.choi
2017. 3. 2. 20:07
반응형
Node js 의 앱을 우분투 부팅시 실행하기
mobius.js (node js로 구동되는 app) 를 우분투 부팅과 동시에 실행하기 위하여 /etc/init/{server name}.conf 를 생성합니다.
$ sudo -s
$ cd /etc/init/
$ nano mobius.conf
그리고 다음과 같은 내용을 붙여 넣습니다.
description "mobius.js"
author "your name"
# used to be: start on startup
# until we found some mounts weren't ready yet while booting
start on started mountall
stop on shutdown
# automatically respawn
respawn
respawn limit 99 5
script
export HOME="/home/udooer/mobius-yt-v2.2.1"
export NODE_ENV=production
chdir /home/udooer/mobius-yt-v2.2.1
exec /usr/bin/node mobius.js >> /var/log/node.log 2>&1
end script
post-start script
# to do something before triggering mobius.js
end script
log는 /var/log/node.log 에 기록되어집니다. 새로운 서비스를 실행하기 위하여 다음의 명령을 실행 합니다. {서비스명}은 {서비스명}.conf 입니다.
$ sudo start {서비스명}
/etc/init/{서비스명}.conf 는 start / restart /reload / status {서비스명} 으로 사용가능합니다.
반응형