每当 EC2 重新启动时,我想启动 nginx 服务以及其他几个 Node js 应用程序。
我创建了
rc.local
。
我在其中添加了以下代码行:
#/etc/startup_script.sh
#actual path to your script file.
/usr/bin/bash /etc/startup_script.sh &
exit 0
startup_script.sh:
sudo systemctl start nginx.service
#start pm2 services
pm2 start npm --name node_server1
pm2 start npm --name node_server2
pm2 start npm --name node_server3
pm2 start npm --name node_server4
pm2 save
出现以下错误
-- Reboot --
Jul 25 14:30:00 ip-10-192-3-238 systemd[1]: Starting /etc/rc.local Compatibility...
Jul 25 14:30:00 ip-10-192-3-238 systemd[1]: rc-local.service: Control process exited, code=exited, status=203/EXEC
Jul 25 14:30:00 ip-10-192-3-238 systemd[1]: rc-local.service: Failed with result 'exit-code'.
Jul 25 14:30:00 ip-10-192-3-238 systemd[1]: Failed to start /etc/rc.local Compatibility.