Community
cancel
Showing results for 
Search instead for 
Did you mean: 
GGerh
New Contributor I
4,348 Views

Yocto .service fail on startup

Hi

i'm running a http://www.dict.cc/?s=custom&failed_kw=custome custom build yocto on my edison, i also use a modem with gps capabilities connected by uart (MFD1).

 

I have a bunch of services running and all work fine but when it comes to my gps service it fails on startup... when i start the binary manueley on the shell everything works fine.. does anybody have a bit more http://www.dict.cc/englisch-deutsch/experience.html experience with systemd services then i do and can help me with that ?

 

root@:~# systemctl status -l simulated_device_cloud_upload

● simulated_device_cloud_upload.service - Azure Iot Gateway as a service.

Loaded: loaded (/lib/systemd/system/simulated_device_cloud_upload.service; disabled)

Active: inactive (dead)

Apr 07 07:19:48 gps_start.sh[594]: time:0 100000

Apr 07 07:19:48 gps_start.sh[594]: OK

Apr 07 07:19:48 GPS ERROR: -1

Apr 07 07:19:48 gps_start.sh[594]: Stop Gps......

Apr 07 07:19:52 start.sh[594]: -- switch to Command Mode - failed 100

Apr 07 07:19:53 gps_start.sh[594]: send: at+gpsstop

Apr 07 07:19:53 gps_start.sh[594]: time:0 100000

Apr 07 07:19:53 start.sh[594]: OK

Apr 07 07:19:53 gps_start.sh[594]: +GPS ERROR: -1

Apr 07 07:19:53 TransAM gps_start.sh[594]: 2017-04-07 07:19:53 ..\src\Interfaces\TAM_UART.cpp on line 89 status: UART object destroyed successfully

root@TransAM:~#

There is a super loop in my code the +GPS ERROR: -1 do not end the programm...

[Unit]

Description=Azure Iot Gateway as a service.

# After=systemd-hostnamed.service

[Service]

# ExecStartPre=/bin/systemctl start wpa_supplicant

ExecStart=/usr/bin/gps_start.sh

Environment="HOME=/usr/bin"

WorkingDirectory=/usr/bin/

# Type=forking

[Install]

WantedBy=multi-user.target

gps_start.sh

# !/bin/sh

/usr/sbin/simulated_device_cloud_upload_sample /usr/sbin/simulated_device_cloud_upload_telematic_hub.json

Tags (2)
0 Kudos
15 Replies
idata
Community Manager
112 Views

Hello gerrik84k,

 

 

Thanks for reaching out!

 

 

I don't think there is anything wrong with your script or your service. I believe the issue is that the service doesn't know when to start, so when it does, it starts before some of its dependency services. Therefore the service loads but nothing happens. There are a couple suggestions I can give you:

 

 

Use Type=idle under [Service]. As you can see at https://www.freedesktop.org/software/systemd/man/systemd.service.html, idle delays the actual execution of the service binary until all active jobs are dispatched.

 

 

If you know exactly which services are needed for your service, then use Requires=XXXXX.service and After=XXXXX.service under [Unit]. As you can also see at https://www.freedesktop.org/software/systemd/man/systemd.service.html Requires= and After= creates dependencies on sysinit.target to ensure that normal service units pull in basic system initialization, and are terminated cleanly prior to system shutdown.

 

 

I hope this information helps you,

 

Pedro M.
GGerh
New Contributor I
112 Views

hello,

i do understand that is important to start all the service which are needed for my service. my question would be why does my service not start if i start it manually when my system is booted with ....

systemctl start simulated_device_cloud_upload

but it do start when i executed from the shell by

/usr/bin/gps_start.sh

for my understanding everything should be equal on both startups

thanks in advance

idata
Community Manager
112 Views

There is a significant detail, the service is already loaded as shown in your original post. So, you would have to first stop the service and then start it again in order to see it actually run.

 

 

Let me know how it goes.

 

Pedro M.
GGerh
New Contributor I
112 Views

After a rebbot i can see

root@TransAM:~# systemctl status simulated_device_cloud_upload

● simulated_device_cloud_upload.service - Azure Iot Gateway as a service.

Loaded: loaded (/lib/systemd/system/simulated_device_cloud_upload.service; disabled)

Active: inactive (dead)

so after stopping

root@TransAM:~# systemctl stop simulated_device_cloud_upload

root@TransAM:~# systemctl status simulated_device_cloud_upload

● simulated_device_cloud_upload.service - Azure Iot Gateway as a service.

Loaded: loaded (/lib/systemd/system/simulated_device_cloud_upload.service; disabled)

Active: inactive (dead)

Apr 12 12:48:49 TransAM systemd[1]: Stopped Azure Iot Gateway as a service..

And then i start the service again, it faield with the output mentioned in the original post

simulated_device_cloud_upload.service - Azure Iot Gateway as a service.

Loaded: loaded (/lib/systemd/system/simulated_device_cloud_upload.service; disabled)

Active: active (running) since Wed 2017-04-12 12:50:02 UTC; 1s ago

Main PID: 449 (simulated_devic)

CGroup: /system.slice/simulated_device_cloud_upload.service

└─449 /usr/sbin/simulated_device_cloud_upload_sample /usr/sbin/simulated_device_cloud_upload_telematic_hub.json

when i start this manual ...

 

root@TransAM:~# /usr/sbin/simulated_device_cloud_upload_sample /usr/sbin/simulated_device_cloud_upload_telematic_hub.json

it works fine

idata
Community Manager
112 Views

That is interesting. I would like to analyze your scripts, I would also like to test them but since you are using Azure, I doubt I will be able to do so.

 

 

Anyhow, could you share all the scripts involved on this service? Perhaps we're missing a small detail on them, for example on the shebang lines.

 

 

Pedro M.
GGerh
New Contributor I
112 Views

i will make a post with all the necessary files, but a question in front i have a lot of printings on std::cout i also can see if my shell dies the service dies also... my that could cause the problem ?

idata
Community Manager
112 Views

Hi gerrik84k,

 

 

Great! We will be waiting for your post.

 

 

We don't think that those prints are causing the issue, but you can try it removing them to see if it works. And be careful with the shebang lines, make sure that you are setting them correctly.

 

 

Have a nice day.

 

 

Regards,

 

Leonardo R.
GGerh
New Contributor I
112 Views

all of my scripts i'm using i mentioned in my first post, i'm using a sample provided by this git repo.

i'm using the simulated device cloud upload sample

 

https://github.com/Azure/azure-iot-gateway-sdk/tree/master/modules/simulated_device/src azure-iot-gateway-sdk/modules/simulated_device/src at master · Azure/azure-iot-gateway-sdk · GitHub https://github.com/Azure/azure-iot-gateway-sdk/tree/master/samples/simulated_device_cloud_upload/src

 

azure-iot-gateway-sdk/samples/simulated_device_cloud_upload/src at master · Azure/azure-iot-gateway-sdk · GitHub

i made a workaround so far that i start my shell script in a screen shell so everything works fine. but thats not what i want.

idata
Community Manager
112 Views

You mentioned that the .service is above but that file does not have any of the modifications I suggested. Did you try those modifications? If so, could you please share the new .service?

 

 

Pedro M.
GGerh
New Contributor I
112 Views

i do used your hints about the service file

[Unit]

Description=Azure Iot Gateway as a service.

# Requires=network-online.target

# After=network.target network-online.target multi-user.target

After=systemd-hostnamed.service

[Service]

# Environment='JSON=/usr/sbin/simulated_device_cloud_upload_telematic_hub.json'

ExecStartPre=/bin/systemctl start wpa_supplicant

# ExecStart=/usr/sbin/simulated_device_cloud_upload_sample ${JSON}

# ExecStart=/etc/init.d/gps_start.sh

# ExecStart=/usr/bin/gps_start.sh

ExecStart=/usr/bin/gps_start.sh -d

# Environment="HOME=/usr/bin"

# WorkingDirectory=/usr/bin/

# Type=forking

Type=idle

# Restart=on-success

# StandardOutput=syslog+console

[Install]

WantedBy=multi-user.target

idata
Community Manager
112 Views

Hello gerrik84k,

 

 

Thank you for providing us this file as well. We'll analyze your case to see if we can find out what might be happening. If we have any useful updates, we'll make sure to post them in here.

 

 

Pedro M.
idata
Community Manager
112 Views

Hello gerrik84k,

 

 

Have you modified the permissions on all the files involved on the service? If so, could you please share the permissions configurations you set them?

 

 

Pedro M.
idata
Community Manager
112 Views

Hello gerrik84k,

 

 

Do you have any updates about this?

 

 

Pedro M.
GGerh
New Contributor I
112 Views

already changed the permission, i do work with my workaround...

idata
Community Manager
112 Views

Were you able to make it work? May I ask if you can share your workaround? I'm sure it will be of help for other users and I'm honestly curious to how you achieved this.

 

 

Pedro M.
Reply