Edison起動時にNode.jsを自動起動させたかった.
起動スクリプトの設定
起動スクリプトのユニット作成
まずは設定ファイルを作る
$ vi /etc/systemd/system/hoge.service
スクリプトの設定例 (Node.jsの場合)
設定ファイルの中身
[Unit]
Description=Node.js Hoge-Server
[Service]
WorkingDirectory=/home/root/Documents/Project/hoge
Type=simple
ExecStart=/usr/bin/node app.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=node-server
[Install]
WantedBy=multi-user.target
スクリプトを開始する
$ systemctl start hoge.service
スクリプトを停止する
$ systemctl stop hoge.service
ログを見る
$ systemctl status hoge.service
起動スクリプトのイネーブル
OS起動時に自動起動させる
$ systemctl enable hoge.service
起動スクリプトのディセーブル
OS起動時に自動起動させない
$ systemctl disable hoge.service
参考サイト