起動スクリプトを/etc/init.dに置く。
起動スクリプトはroot権限で実行されるため、runuserを使ってec2-user権限で実行するようにする。例は以下。
runuser -l ec2-user -c "cd /home/ec2-user/project && ./start_server.sh"
もっとちゃんと書くなら以下が参考になる。
node.js init.d script for CentOS
起動スクリプトを/etc/init.dに置く。
起動スクリプトはroot権限で実行されるため、runuserを使ってec2-user権限で実行するようにする。例は以下。
runuser -l ec2-user -c "cd /home/ec2-user/project && ./start_server.sh"
もっとちゃんと書くなら以下が参考になる。
node.js init.d script for CentOS