this is my first post here and I’m about to get crazy. I developed a Car-PC system with an Arduino to get CAN-Bus messages (e.g. Steering Wheel Controls). Now, when OSMC has booted, it should start my script, which gets connected to Kodi to interpret the arduino CAN-Bus messages.
It works fine, as long as OSMC boots with network connection (tested it with an mobile hotspot). But If there is no network connection, it wont start my script.
My Service: /lib/systemd/system/control.service
[Unit]
Description = Catch controls
After = remote-fs.target
[Service]
Type = forking
RemainAfterExit=yes
ExecStart = /path/to/script
[Install]
WantedBy = multi-user.target
Do you mean it won’t start the script or the script doesn’t run/do what it’s supposed to do? I think we would need to see your script to comment properly.
The script doesn’t start, it does what it should do.
What I think is, that OSMC / Kodi waits for a network connection to sychronize the time(?)
And when this fails, then it doesn’t trigger the service /script.
Could that be? Is there a possibility to disable time synchronization on boot ?
(graphical.target will also work). This is the equivalent of saying wait until runlevel 5 has been reached before kicking off the process.
Well, you have the line After = remote-fs.target so that makes sense if, due to a lack of network, remote-fs.target can’t start. Are you therefore sure you need this dependency?
Unfortunately it doesn’t work… same behavior, but know, even if there is network connection it does not work. If I start the service by my own: ‘sudo systemctl start control.service’ everything works fine…
Is there a way to stop searching for network and timeserver? That even affects the boot time
Jul 24 23:37:34 BMW-EC systemd[1]: Found ordering cycle on graphical.target/start
Jul 24 23:37:34 BMW-EC systemd[1]: Found dependency on multi-user.target/start
Jul 24 23:37:34 BMW-EC systemd[1]: Found dependency on controls.service/start
Jul 24 23:37:34 BMW-EC systemd[1]: Found dependency on graphical.target/start
Jul 24 23:37:34 BMW-EC systemd[1]: Breaking ordering cycle by deleting job controls.service/start
Jul 24 23:37:34 BMW-EC systemd[1]: Job controls.service/start deleted to break ordering cycle starting with graphical.target/start
causing the service to be deleted from the startup order.
Since it seems that you don’t need network connectivity, perhaps revert to @joakim_s’s suggestion [quote=“joakim_s, post:2, topic:37838, full:true”]
Try to replace:
The error is being thrown at line 1197 in /usr/lib/python2.7/urllib2.py. The file is readable text so you can view it yourself. At what point does the process now try to start? I also notice that you removed the sleep 10 from the shell script, so you’ve lost the delay before running the python script. It might be worth adding it again or placing a line in controls.service ExecStartPre=/bin/sleep 10 .
(Just as an aside, you can run /home/osmc/scripts/control.py just like a shell script by having #!/usr/bin/python on the first line and making the file executable.)
Some questions:
What is the reason for including RemainAfterExit=yes?
Why did you choose Type=forking, rather than Type=simple?
Oh sorry, it was late and I misunderstood this.
I will correct it to:
WantedBy=multi-user.target.
I understood this as a piece of advice to remove it. I try adding the delay again.
First, I try to get it work like this so I can exclude Black Linux/Kodi/OSMC magic that makes my code fail. Then I can try to minimize it like this, thank you.
I had Problems keeping the service up while Kodi is running, I now don’t really know if it was a fault of the service or in my code because I couldn’t work on that project for a quite long time now and I forgot some things.
The service has to run all the time because it interprets the control of my steering wheel and iDrive (BMW).
Same reason here, I just tried let it run continuously next to the system.
I really searched for a documentation that explains all these parameters. All I found were just a few examples where I read “forking” and thought that would be a good idea.
Same thing with “remote-fs.target”. Just saw that in a example and tried it.
Thank you for your support, I really appreciate it.