5 Replies Latest reply on Apr 25, 2016 12:21 PM by MateuszJodkowski

    Startup scripts on Edison

    rubidium

      I'm aware of the ability to have a *login* script on Edison in the form of ".profile" on /home.  I was wondering what options there are for a *boot* startup script, so that I can launch applications on a headless system. I son't see anything line an "/etc/rc.local".

      Jim

        • 1. Re: Startup scripts on Edison
          raminf

          Yocto uses the 'systemd' daemon to manage system startup tasks. More information: https://wiki.archlinux.org/index.php/systemd

          • 2. Re: Startup scripts on Edison
            David_J_Hunt

            I believe this is answered elswhere, but here it is for convenience:

             

            Edison uses systemd for starting and stopping serviices, so you can have a script started using this method at boot.

             

            Add a new service script to /lib/systemd/system - have a look at the scripts alreadythere, a good example is the iotkit-agent.service script.

            So you then have yourscript.service file.

            To start, first refresh systemd, then try to start your new service

               systemctl daemon-reload

               systemcrl start yourscript.service

             

            You can then use 'systemctl status yourscript.service' to see if it's started and alive.

             

            If you want it to start at boot, you have to 'enable' it

               systemcrl enable yourscript.service 

            which creates a softlink to your script from the relevant directory in /etc/systemd/system/...

            Now reboot and see if it comes up ok.

             

            If your script calls a binary that needs environment vars set up, be sure to include them in the script, LD_LIBRARY_PATH is a common var needed:

            LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

            export LD_LIBRARY_PATH

             

            Rgds,

            Dave.

            1 of 1 people found this helpful
            • 3. Re: Startup scripts on Edison
              BoraTuran

              Hi,  I am trying to start a node.js app on startup. I have the following system service file. I am getting an error with the following ExecStart line, am I doing something wrong?

               

              ExecStart=/usr/bin node /node_app_slot/main.js


              Details

              ------------------------------------------------------------

               

              root@Alvin5Edison:~# cat  /lib/systemd/system/alvin5StartUp.service

              [Unit]

              Description=alvin5Startup

              After=network.target

               

              [Service]

              ExecStart=/usr/bin node /node_app_slot/main.js

              Restart=always

              RestartSec=1s

              Environment=NODE_ENV=production

               

              [Install]

              WantedBy=multi-user.target

              root@Alvin5Edison:~#

              root@Alvin5Edison:~# systemctl daemon-reload

              root@Alvin5Edison:~# systemctl start  alvin5StartUp -l

              root@Alvin5Edison:~# systemctl status alvin5StartUp -l

              alvin5StartUp.service - alvin5Startup

                 Loaded: loaded (/lib/systemd/system/alvin5StartUp.service; enabled)

                 Active: failed (Result: start-limit) since Tue 2014-11-11 08:02:03 UTC; 641ms ago

                Process: 479 ExecStart=/usr/bin node /node_app_slot/main.js (code=exited, status=203/EXEC)

              Main PID: 479 (code=exited, status=203/EXEC)

               

              Nov 11 08:02:03 Alvin5Edison systemd[1]: alvin5StartUp.service holdoff time over, scheduling restart.

              Nov 11 08:02:03 Alvin5Edison systemd[1]: Stopping alvin5Startup...

              Nov 11 08:02:03 Alvin5Edison systemd[1]: Starting alvin5Startup...

              Nov 11 08:02:03 Alvin5Edison systemd[1]: alvin5StartUp.service start request repeated too quickly, refusing to start.

              Nov 11 08:02:03 Alvin5Edison systemd[1]: Failed to start alvin5Startup.

              Nov 11 08:02:03 Alvin5Edison systemd[1]: Unit alvin5StartUp.service entered failed state.

              root@Alvin5Edison:~#

              • 4. Re: Startup scripts on Edison
                Christoph.P

                David_J_Hunt schrieb:



                I believe this is answered elswhere, but here it is for convenience:


                Edison uses systemd for starting and stopping serviices, so you can have a script started using this method at boot.


                Add a new service script to /lib/systemd/system - have a look at the scripts alreadythere, a good example is the iotkit-agent.service script.

                So you then have yourscript.service file.

                To start, first refresh systemd, then try to start your new service

                systemctl daemon-reload


                systemctl start yourscript.service



                You can then use 'systemctl status yourscript.service' to see if it's started and alive.


                If you want it to start at boot, you have to 'enable' it

                systemcrl enable yourscript.service

                which creates a softlink to your script from the relevant directory in /etc/systemd/system/...

                Now reboot and see if it comes up ok.


                If your script calls a binary that needs environment vars set up, be sure to include them in the script, LD_LIBRARY_PATH is a common var needed:

                LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

                export LD_LIBRARY_PATH


                Rgds,

                Dave.

                Grrrrrrrrr

                Took me 30 Minutes to see the fault...

                • 5. Re: Startup scripts on Edison
                  MateuszJodkowski

                  Hi, I make project silmilar to Basketball Robot with Intel Edison. I want to start node application automatically after linux start. I try to use System Service Manager, but unfortunately it doesn't work and I have no idea why? I maked "myfilename.services" file, here is a code:

                  //////////////////////////////////////////////////////

                  [Unit]

                  Description=Open Automation Service

                  After=network.service

                  [Service]

                  ExecStart=/bin/sh -c "/usr/bin/node /home/root/robotServer/myprogramname.js"

                  WorkingDirectory=/home/root/robotServer/node_modules/

                  Restart=always

                  RestartSec=5s

                  [Install]

                  WantedBy=multi-user.target

                  //////////////////////////////////////////////////////

                  Then I configured Intel Edison:

                  #### Set executable rights to everyone:

                  chmod 777 /etc/systemd/system/myfilename.service

                  #### Reload systemctl daemon:

                  systemctl daemon-reload

                  #### Start your service:

                  systemctl start myfilename.service

                  #### Check service status:

                  systemctl status

                  systemctl status myfilename.service

                  #### Enable service autostart feature:

                  systemctl enable myfilename.service

                   

                  Despite ".servises" program are running, my script doesn't work (ps. script start very well from console). Where can be problem? How can I localize problem?

                   

                  Untitled.jpg