Для этого я выполнил несколько шагов, первый из которых — установка статического IP-адреса моего pi. .
Вторым шагом, который я прошел, было создание нового сценария, который может запускать мое приложение с потоковой подсветкой (другой файл Python) из нового сценария Python. Код для этого показан ниже.
Код: Выделить всё
from streamlit.web import cli as stcli
import sys
if __name__ == "__main__":
script_path = "/home/pi/daqhats/examples/python/mcc128/daqhat_burster_plot.py"
sys.argv = ["streamlit", "run", script_path]
stcli.main()
С этого момента мое намерение заключалось в следующем: чтобы файл run_streamlit_scripts выполнялся автоматически при включении pi, чтобы я мог получить доступ к веб-серверу без необходимости вручную вводить данные в терминал.
Для этого я выполнил процесс создание служебного файла в моем каталоге systemd. Я хочу работать с systemd, поскольку, как я читал, это наиболее надежный способ запуска файлов при запуске по сравнению с локальным rc и автозапуском.
Код: Выделить всё
[Unit]
Description=Run streamlit scripts automatically
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/daqhats/examples/python/mcc128/run_streamlit_scripts.py
WorkingDirectory=/home/pi
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
Код: Выделить всё
run_streamlit_scripts.service - Run streamlit scripts automatically
Loaded: loaded (/lib/systemd/system/run_streamlit_scripts.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-06-24 15:47:25 EDT; 3min 13s ago
Duration: 68ms
Process: 1037 ExecStart=/usr/bin/python3 /home/pi/daqhats/examples/python/mcc128/run_streamlit_scripts.py (code=exited, status=1/FAILURE)
Main PID: 1037 (code=exited, status=1/FAILURE)
CPU: 68ms
Jun 24 15:47:25 raspberrypi systemd[1]: run_streamlit_scripts.service: Scheduled restart job, restart counter is at 5.
Jun 24 15:47:25 raspberrypi systemd[1]: Stopped run_streamlit_scripts.service - Run streamlit scripts automatically.
Jun 24 15:47:25 raspberrypi systemd[1]: run_streamlit_scripts.service: Start request repeated too quickly.
Jun 24 15:47:25 raspberrypi systemd[1]: run_streamlit_scripts.service: Failed with result 'exit-code'.
Jun 24 15:47:25 raspberrypi systemd[1]: Failed to start run_streamlit_scripts.service - Run streamlit scripts automatically.
Подробнее здесь: https://stackoverflow.com/questions/786 ... spberry-pi