Вот один из моих служебных файлов (я тестирую очень много):
Код: Выделить всё
[Unit]
Description= Flask_serveur
[Service]
#WorkingDirectory=/home/pi/flask
ExecStart=/usr/bin/python3 /usr/bin/flask run --host=10.2.43.223
StandardOut=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target
Код: Выделить всё
● serveur_flask.service - Flask_serveur
Loaded: loaded (/etc/systemd/system/serveur_flask.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-09-19 11:59:01 CEST; 41s ago Process: 465 ExecStart=/home/pi/flask/autostart_flask.sh (code=exited, status=2) Main PID: 465 (code=exited, status=2)
CPU: 1.275s
sept. 19 11:59:00 raspberrypi autostart_flask.sh[481]: * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them. sept. 19 11:59:01 raspberrypi autostart_flask.sh[481]: * Environment: production sept. 19 11:59:01 raspberrypi autostart_flask.sh[481]: WARNING: This is a development server. Do not use it in a production deployment. sept. 19 11:59:01 raspberrypi autostart_flask.sh[481]: Use a production WSGI server instead. sept. 19 11:59:01 raspberrypi autostart_flask.sh[481]: * Debug mode: off sept. 19 11:59:01 raspberrypi autostart_flask.sh[481]: Usage: flask run [OPTIONS] sept. 19 11:59:01 raspberrypi autostart_flask.sh[481]: Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in> sept. 19 11:59:01 raspberrypi systemd[1]: serveur_flask.service: Main process exited, code=exited, status=2/INVALIDARGUMENT sept. 19 11:59:01 raspberrypi systemd[1]: serveur_flask.service: Failed with result 'exit-code'. sept. 19 11:59:01 raspberrypi systemd[1]: serveur_flask.service: Consumed 1.275s CPU time.
Я пробую некоторые советы из stackiverflow, например номер 65433929, но у меня не работает..
Подробнее здесь: https://stackoverflow.com/questions/790 ... nvironment