#author("2025-02-02T21:34:24+09:00","default:BotComputing-WikiIoT","BotComputing-WikiIoT")
#author("2025-02-02T21:37:33+09:00","default:BotComputing-WikiIoT","BotComputing-WikiIoT")
[[FrontPage]]

* systemd [#wdf03b32]
 /etc/systemd/system

 sudo emacs reboot.service

#code(){{
[Unit]
Description = Reboot
RefuseManualStart = true
RefuseManualStop = true

[Service]
ExecStart = /sbin/reboot

}}

 sudo emacs reboot.timer

#code(){{
[Unit]
Description = Weekly Reboot Timer

[Timer]
OnCalendar=*-*-* 10:05:00

[Install]
WantedBy = timers.target

}}

 sudo systemctl enable reboot.timer
 sudo systemctl start reboot.timer

 sudo emacs wiki_bot.service

#code(){{
[Unit]
Description=wiki_bot
After=network.target
 
[Service]
User=pi
Type=simple
WorkingDirectory=/home/pi/python
ExecStart=/home/pi/python/start_wiki_bot.sh
 
[Install]
WantedBy=multi-user.target

}}

 sudo systemctl enable wiki_bot.service

 emacs /home/pi/python/start_wiki_bot.sh   
 chmod 755 /home/pi/python/start_wiki_bot.sh

#code(){{
#!/bin/sh
sleep 120
xhost +
export DISPLAY=:0.0
python3 wiki_bot_02.py -s

}}

requests_toolbelt は、仮想環境でpip3しないと入らなかった。
requests_toolbelt, pyserial は、仮想環境でpip3しないと入らなかった。

仮想環境の構築
https://blog.piwheels.org/debian-bookworm-and-raspberry-pi-5/
を参考に

 $ sudo apt install virtualenv python3-virtualenv -y
 $ virtualenv -p /usr/bin/python3 testpip

を実行して環境を構築。

 $ source testpip/bin/activate

を実行して仮想環境に入る。

 pip3 install requests_toolbelt
 pip3 install pyserial

で requests_toolbelt , pyserial を install
で requests_toolbelt と pyserial を install

wiki_bot_03.py を仮想環境で起動。
仮想環境で起動する場合の start_wiki_bot.sh 

#code(){{
#!/usr/bin/bash
sleep 120
xhost +
export DISPLAY=:0.0
cd /home/pi/python
source testpip/bin/activate
python3 wiki_bot_03.py -s
python3 wiki_bot_04.py -s
}}
----
#counter

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS