headlessで運用するRapsberry Piのシステムを開発中です。基幹となるサービスがnodeで動くので、システム起動時に自動的に起動するように設定してみました。RaspbianがWheesyまでのときはinsservでよかったのですが、Jessieからはsystemdに変わっています。insservでも起動できるのは確認しているのですが、折角ですのでsystemdでの起動に挑戦してみます。参考にしたのはこちら。Systemdを使ってさくっと自作コマンドをサービス化してみる – QiitaNode-RED.serviceまずserviceファイルを書きます。 pi@raspberrypi:~ $ sudo nano /etc/systemd/system/node-kt.service rootで起動するのがセキュリティ的に望ましくないことは分かってはいるのですが、システムレベル、ハードウェアレベルにアクセスしないといけない関係上、やむを得ずrootにしています。 [Unit]Description=Node.js kawacchi timer serverAfter=syslog.target network.target[Service]ExecStart=/usr/local/bin/node /home/pi/kt/app.jsRestart=alwaysRestartSec=10 # Restart service after 10 seconds if node service crash$StandardOutput=syslog # Output to syslogStandardError=syslog # Output to syslogSyslogIdentifier=nodejs-ktUser=rootGroup=root[Install]WantedBy=multi-user.target 保存したところ、systemctlコマンドで認識できました。 pi@raspberrypi:~ $ sudo systemctl list-unit-files --type=service | grep nodekmod-static-nodes.service static…
Continue reading...