sumnerboy12 / mqtt-gpio-monitor

Python script for sending/receiving commands to/from GPIO pins via MQTT messages
46 stars 23 forks source link

Run as .service #32

Open zuhra031 opened 5 years ago

zuhra031 commented 5 years ago

Hi, Im trying to run mqtt-gpio-monitor as service on boot @ rasbian (latest)

.service file (/lib/systemd/system/mqtt-gpio-monitor-service.service)

[Unit]
Description=MQTT Buttons
After=multi-user.target

[Service]
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=MQTTGPIOMon
User=pi
Group=pi
WorkingDirectory=/home/pi/gregorb/mqtt-gpio-monitor/
ExecStart=/usr/bin/python3 /home/pi/gregorb/mqtt-gpio-monitor/mqtt-gpio-monitor.py

[Install]
WantedBy=multi-user.target

when i run enable and then status I get

● mqtt-gpio-monitor-service.service - MQTT Buttons
   Loaded: loaded (/lib/systemd/system/mqtt-gpio-monitor-service.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-06-09 23:03:48 CEST; 24h ago
 Main PID: 899 (code=exited, status=2)

Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Unit entered failed state.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Failed with result 'exit-code'.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Service hold-off time over, scheduling restart.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: Stopped MQTT Buttons.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Start request repeated too quickly.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: Failed to start MQTT Buttons.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Unit entered failed state.
Lip 09 23:03:48 WiseMagicMirror systemd[1]: mqtt-gpio-monitor-service.service: Failed with result 'exit-code'.

When i try to run it via terminal with command /usr/bin/python3 /home/pi/gregorb/mqtt-gpio-monitor/mqtt-gpio-monitor.py I get

Traceback (most recent call last):
  File "/usr/lib/python3.5/configparser.py", line 1135, in _unify_values
    sectiondict = self._sections[section]
KeyError: 'global'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/gregorb/mqtt-gpio-monitor/mqtt-gpio-monitor.py", line 30, in <module>
    MODULE = config.get("global", "module")
  File "/usr/lib/python3.5/configparser.py", line 778, in get
    d = self._unify_values(section, vars)
  File "/usr/lib/python3.5/configparser.py", line 1138, in _unify_values
    raise NoSectionError(section)
configparser.NoSectionError: No section: 'global'

when i cd to root dir of script, I can run it with python3 mqtt-gpio-monitor.py.

Any ideas how to run it as service? Thanks, G.