[Reboot]Automatically start forever (node) on system restart > Linux/Tech

본문 바로가기

사이트 내 전체검색

Linux/Tech

[Reboot]Automatically start forever (node) on system restart

작성일 22-03-11 13:53

페이지 정보

작성자sbLAB 조회 4,187회 댓글 0건

본문

[정상작동 안됨]


forever path => /usr/local/bin

----------------------------------------------


1. Create a bash script file (change bob to desired user).

vi /home/bob/node_server_init.sh

2. Copy and paste this inside the file you've just created.

#!/bin/sh

export NODE_ENV=production
export PATH=/usr/local/bin:$PATH
forever start /node/server/path/server.js > /dev/null

Make sure to edit the paths above according to your config!


3. Make sure the bash script can be executed.

chmod 700 /home/bob/node_server_init.sh

4. Test the bash script.

sh /home/bob/node_server_init.sh

5. Replace "bob" with the runtime user for node.

crontab -u bob -e 

6. Copy and paste (change bob to desired user).

@reboot /bin/sh /home/bob/node_server_init.sh

Save the crontab.


service cron  restart 

service cron  status


7. You've made it to the end, your prize is a reboot 



https://stackoverflow.com/questions/13385029/automatically-start-forever-node-on-system-restart 

https://nextrend.co/157/%EB%A6%AC%EB%88%85%EC%8A%A4-%EC%9E%91%EC%97%85-crontab%ED%81%AC%EB%A1%A0%ED%83%AD-%EC%A0%81%EC%9A%A9%EC%8A%A4%EC%BC%80%EC%A4%84%EB%9F%AC-%EB%B0%8F-%EC%98%A4%EB%A5%98-%ED%95%B4%EA%B2%B0-%EB%B0%A9/ 


[etc]

@reboot = run at boot and reboot only

@yearly  = run at midnight Jan 1 each year (equiv to 0 0 1 1 *)

@annually  = run at midnight Jan 1 each year (equiv to 0 0 1 1 *)

@monthly  = run at midnight on the first day of each month (equiv to 0 0 1 * *)

@weekly  = run at midnight each Sunday (equiv to 0 0 * * 0)

@daily  = run at midnight each day (equiv to 0 0 * * *)

@ midnight  = run at midnight each day (equiv to 0 0 * * *)

@ hourly = run on the first second of every hour (equiv to 0 * * * *)

댓글목록

등록된 댓글이 없습니다.

Copyright © 소유하신 도메인. All rights reserved.
PC 버전으로 보기