1 2 Previous Next 15 Replies Latest reply on May 2, 2017 1:28 PM by Intel Corporation

    Yocto .service fail on startup

    gerrik84k

      Hi

       

      i'm running a 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 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

        • 1. Re: Yocto .service fail on startup
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          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.

          • 2. Re: Yocto .service fail on startup
            gerrik84k

            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

            • 3. Re: Yocto .service fail on startup
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              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.

              • 4. Re: Yocto .service fail on startup
                gerrik84k

                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

                • 5. Re: Yocto .service fail on startup
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  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.

                  • 6. Re: Yocto .service fail on startup
                    gerrik84k

                    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 ?

                    • 7. Re: Yocto .service fail on startup
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      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.

                      • 8. Re: Yocto .service fail on startup
                        gerrik84k

                        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
                        azure-iot-gateway-sdk/modules/simulated_device/src at master · Azure/azure-iot-gateway-sdk · GitHub
                        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.

                        • 9. Re: Yocto .service fail on startup
                          Intel Corporation
                          This message was posted on behalf of Intel Corporation

                          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.

                          • 10. Re: Yocto .service fail on startup
                            gerrik84k

                            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

                            • 11. Re: Yocto .service fail on startup
                              Intel Corporation
                              This message was posted on behalf of Intel Corporation

                              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.

                              • 12. Re: Yocto .service fail on startup
                                Intel Corporation
                                This message was posted on behalf of Intel Corporation

                                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.

                                • 13. Re: Yocto .service fail on startup
                                  Intel Corporation
                                  This message was posted on behalf of Intel Corporation

                                  Hello gerrik84k,

                                  Do you have any updates about this?

                                  Pedro M.

                                  • 14. Re: Yocto .service fail on startup
                                    gerrik84k

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

                                    1 2 Previous Next