ラズパイのプロジェクト配下にサービスを設置してシンボリックリンクを張って、systemdで自動起動設定をする
株式会社XSHELL デベロッパー 植田歩
環境
- mac OS X El Capitan
- Raspberry Pi 3
- OS 2017-08-16-raspbian-stretch-lite.img
手順
/etc/systemd/systemから~/git/office_monitorにシンボリックリンクをはり、自動起動設定をする
シンボリックリンク作成
sudo ln -s ~/git/office-monitor/office-monitor.service /etc/systemd/system
sudo service office-monitor start
sudo service office-monitor stop
.serviceの書き方は調べてください。
一応サンプルです。
別プロジェクトのものなのでパスとサービス名が違います。
[Unit]
Description=thermo
Before=network.target
After=syslog.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/thermo
ExecStart=/usr/bin/python2 /home/pi/thermo/serial-thermo.py
ExecStop=
Restart = always
TimeoutStopSec=60
StandardOutput=null
[Install]
WantedBy = multi-user.target
下記、自動起動設定コマンド
sudo systemctl enable office-monitor.service
sudo systemctl status office-monitor.service
XSHELLはSBCを使いやすくするソリューションを提供しています。
isaax、IoTitぜひご使用になってご意見を頂きたく思います。
共に素晴らしいプロジェクトを実現させましょう!