-1

I installed a python program from a github repo with an automatic script. It is configured to launch itself as a service on startup, and everything seems working fine. I edited the 'py' file to change and improve program, but when I save it I cannot start it anymore as service. If I ask for status it says

Process: 593 ExecStop=/usr/bin/curl http://127.0.0.1/save (code=exited, status=7)
Process: 591 ExecStart=/opt/hue-emulator/HueEmulator3.py (code=exited, status=203/EXEC)

Instead, if I try to launch directly using:

sudo python3 /opt/hue-emulator/HueEmulator3.py

everything seems to works fine. What I'm doing wrong?

EDIT: This is the repo: https://github.com/diyhue/diyHue and this is the systemctl cat hue-emulator.service output

[Unit]
Description=Hue Emulator Service
After=multi-user.target

[Service]
Type=idle
Restart=always
RestartSec=30
StartLimitInterval=200
StartLimitBurst=5

WorkingDirectory=/opt/hue-emulator
ExecStart=/opt/hue-emulator/HueEmulator3.py
ExecStop=/usr/bin/curl http://127.0.0.1/save
ExecStop=/bin/sleep 1

[Install]
WantedBy=multi-user.target

It seems the simple file editing cause this issue. I tried to resinstall via script, then simple add a space then save and it will not run anymore as service. To edit I use notepad++ on Windows using a shared folder via Samba. I also tried to check permissions before and after and I got:

-rwxr-xr-x (before)
-rw-r-xr-x (after)

I fixed them with chmod, but without success.

  • 1
    is the service process also running python3? ..... i did not downvote your post, so i suspect that you have not done enough research before you posted your question – jsotola Jan 20 at 23:30
  • You need to add a bit more info like, what repo and output from log... – MatsK Jan 21 at 8:51
  • Please edit your question and add the output of systemctl cat your.service. – Ingo Jan 21 at 15:21
0

You only give us stripped information, e.g. with the status of the service and with chmod. Executing sudo chmod ... must change the permissions, otherwise you don't have a default Raspbian installation. Don't use notepad from MS Windows. There may be an issue with line delimiter CR+LF (carriage return + line feed) or encoding not being UTF-8. Instead use editor on Raspbian. Unix expects as line delimiter only LF.

  • yeah, chmod is executed as root, I didn't write it becasue is 99% the way to do it. The editor is not classic notepad, but Notepad++ which usually don't break encoding and line ending with different format. By the way I don't think the problem is related to these things, due to the py run smoothly when executed directly, the issue is only when I try to launch it as service. – Noisemaker Jan 21 at 23:16
  • @Noisemaker If chmod doesn't work then please use a default Raspbian installation. Nevertheless you should try editor on the Raspberry Pi for verification. There may be also an encoding issue with the samba share. – Ingo Jan 21 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.