0

EDIT:

I wrote a python script that starts mosquitto client with TLS options ON. All worked fine when I run it from command line (w/o sudo). Now it broke after re-installing some packages.

However, I needed the script to start on system boot, so I created a SYSTEMD service to run as a daemon. Based on the service status report, I infer that the cert or key files are not available, so the daemon exists with error. The files are in the same directory as the .py script. Any ideas what the problem could be?

pi@raspberrypi:~/FONA_PROJECT $ sudo systemctl status fonagps.service 
● fonagps.service - Vechicle Tracking System
Loaded: loaded (/lib/systemd/system/fonagps.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-03-19 22:17:59 UTC; 3s ago
Process: 1526 ExecStart=/usr/bin/python /home/pi/FONA_PROJECT/iot_sub.py (code=exited, status=1/FAILURE)
Main PID: 1526 (code=exited, status=1/FAILURE)

Mar 19 22:17:59 raspberrypi systemd[1]: Started Vechicle Tracking System.
Mar 19 22:17:59 raspberrypi python[1526]: Traceback (most recent call last):
Mar 19 22:17:59 raspberrypi python[1526]:   File "/home/pi/FONA_PROJECT/iot_sub.py", line 129, in <module>
Mar 19 22:17:59 raspberrypi python[1526]:     client.tls_set(ca_certs=ca_certs, certfile=certfile, keyfile=keyfile, cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)
Mar 19 22:17:59 raspberrypi python[1526]:   File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 694, in tls_set
Mar 19 22:17:59 raspberrypi python[1526]:     context.load_cert_chain(certfile, keyfile)
Mar 19 22:17:59 raspberrypi python[1526]: IOError: [Errno 2] No such file or directory
Mar 19 22:17:59 raspberrypi systemd[1]: fonagps.service: Main process exited, code=exited, status=1/FAILURE
Mar 19 22:17:59 raspberrypi systemd[1]: fonagps.service: Unit entered failed state.
Mar 19 22:17:59 raspberrypi systemd[1]: fonagps.service: Failed with result 'exit-code'.
Nazar
  • 103
  • 5

0 Answers0