Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Autostart after boot failing
#1
Hi,
I have followed the directions to start the service automatically. 
However, after reboot the status is this:

pi@irrigate:~ $ systemctl status sip
● sip.service - SIP
   Loaded: loaded (/etc/systemd/system/sip.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019-04-13 08:59:06 AEST; 1min 8s ago
  Process: 388 ExecStart=/usr/bin/python -u /home/pi/SIP/sip.py (code=exited, status=1/FAILURE)
 Main PID: 388 (code=exited, status=1/FAILURE)

Apr 13 08:59:06 irrigate sip[388]:   File "/home/pi/SIP/sip.py", line 202, in run
Apr 13 08:59:06 irrigate sip[388]:     return web.httpserver.runsimple(func, (ip, port))
Apr 13 08:59:06 irrigate sip[388]:   File "/home/pi/SIP/web/httpserver.py", line 157, in runsimple
Apr 13 08:59:06 irrigate sip[388]:     server.start()
Apr 13 08:59:06 irrigate sip[388]:   File "/home/pi/SIP/web/wsgiserver/__init__.py", line 1753, in start
Apr 13 08:59:06 irrigate sip[388]:     raise socket.error(msg)
Apr 13 08:59:06 irrigate sip[388]: socket.error: No socket could be created
Apr 13 08:59:06 irrigate systemd[1]: sip.service: Main process exited, code=exited, status=1/FAILURE
Apr 13 08:59:06 irrigate systemd[1]: sip.service: Unit entered failed state.
Apr 13 08:59:06 irrigate systemd[1]: sip.service: Failed with result 'exit-code'.

If I do this then all ok:

pi@irrigate:~ $ sudo systemctl start sip
pi@irrigate:~ $ systemctl status sip
● sip.service - SIP
   Loaded: loaded (/etc/systemd/system/sip.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-04-13 09:08:40 AEST; 5s ago
 Main PID: 577 (python)
   CGroup: /system.slice/sip.service
           └─577 /usr/bin/python -u /home/pi/SIP/sip.py

Apr 13 09:08:41 irrigate sip[577]:   plugin_manager
Apr 13 09:08:41 irrigate sip[577]:   relay_board
Apr 13 09:08:41 irrigate sip[577]:   signaling_examples
Apr 13 09:08:41 irrigate sip[577]:   system_update
Apr 13 09:08:41 irrigate sip[577]: http://10.0.0.10:80/Starting timing loop
Apr 13 09:08:41 irrigate sip[577]: 10.0.0.155:5688 - - [13/Apr/2019 09:08:41] "HTTP/1.1 GET /rss" - 200 OK
Apr 13 09:08:42 irrigate sip[577]: 10.0.0.155:5688 - - [13/Apr/2019 09:08:42] "HTTP/1.1 GET /rss" - 200 OK
Apr 13 09:08:43 irrigate sip[577]: 10.0.0.155:5688 - - [13/Apr/2019 09:08:43] "HTTP/1.1 GET /rss" - 200 OK
Apr 13 09:08:44 irrigate sip[577]: 10.0.0.155:5688 - - [13/Apr/2019 09:08:44] "HTTP/1.1 GET /rss" - 200 OK
Apr 13 09:08:45 irrigate sip[577]: 10.0.0.155:5688 - - [13/Apr/2019 09:08:45] "HTTP/1.1 GET /rss" - 200 OK
pi@irrigate:~ $

Any help appreciated
Reply
#2
The error "socket.error: No socket could be created" indicates that there is already something using the default port (port 80).

Do you have another server program like apache running?

Once you get SIP to start you can change the port it uses from the Options page. Change "HTTP port:" from 80 to something like 8080. This may help.
You will then need to add the port to the URL when you access SIP for example http://x.x.x.x:8080

I have seen this happen after starting SIP manually and then trying to start it using systemctl.
Reply
#3
(2019 Apr 13, 12:38 AM)dan Wrote: The error "socket.error: No socket could be created" indicates that there is already something using the default port (port 80).

Do you have another server program like apache running?

Once you get SIP to start you can change the port it uses from the Options page. Change "HTTP port:" from 80 to something like 8080. This may help.

I have seen this happen after starting SIP manually and then trying to start it using systemctl.

Thanks dan.
I stopped autostart and rebooted.
sudo netstat -pln, nothing on port 80
started sip
port 80 now in use.
changed port to 8080 and tested ok.
set up auto start
rebooted, error still there even though now on 8080.
start sip and web page responds on 8080

I am inclined to think it is a timing issue but I don't know how to delay the service start.
Reply
#4
I have not seen this problem before and I don't know of a way do delay the auto start.

You might try uising rc.local to start SIP even though it is not the best solution.

If I find another solution I will post it here.
Reply
#5
Apparently you can use a sleep statement in the unit file (sip.service)

https://stackoverflow.com/questions/4300...in-systemd
Reply
#6
I have found an answer.

sudo nano /etc/systemd/system/sip.service

And modify like this:

[Service]
ExecStartPre=-/bin/sleep 10
ExecStart=/usr/bin/python -u /home/pi/SIP/sip.py

This has fixed it for me.
Reply
#7
Great!

Learned a new trick today.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)