• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

How to restart ES from a script?

Scheduled Pinned Locked Moved Help and Support
scriptessystems.cfgrestart
111 Posts 5 Posters 39.9k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    cyperghost
    last edited by 16 Jun 2017, 15:14

    yes that's it...

    You see so it works...
    You killed ES with PID 941

    This was terminated

    and relaunched as new
    ES with PID 1500

    meleus script would kill
    938 and 941
    you can check with (the -e parameter shows list of killed PIDs)

    pkill -f -e "/opt/retropie/supplementary.*emulationstation([^.]|$)"
    

    after meleus script all emulationstation PIDs are gone >> dead!

    B 1 Reply Last reply 16 Jun 2017, 15:15 Reply Quote 0
    • B
      BuZz administrators @cyperghost
      last edited by BuZz 16 Jun 2017, 15:15

      @cyperghost What's the problem with sending a SIGINT to all processes rather than one ?

      @TMNTturtlguy es-restart will get removed by the ES launch script hence why it disappears.

      To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

      C 1 Reply Last reply 16 Jun 2017, 15:18 Reply Quote 1
      • C
        cyperghost @BuZz
        last edited by cyperghost 16 Jun 2017, 15:18

        @BuZz Well ... You are the coding wizard :)

        I think if you show us a way to solve this proper please go on.
        Maybe you can make this waterproof? Or tell us something behind the scene of RetroPie?
        Your are welcome!

        B 1 Reply Last reply 16 Jun 2017, 15:19 Reply Quote 0
        • B
          BuZz administrators @cyperghost
          last edited by BuZz 16 Jun 2017, 15:19

          @cyperghost I'm not sure what the problem is ? :)

          [edit] is it still the same issue as in the OP ? I'd have to test, but it should be ok to killall on ES, which would also kill the current running script of course as it's a child process itself.

          To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

          C 1 Reply Last reply 16 Jun 2017, 15:22 Reply Quote 0
          • C
            cyperghost @BuZz
            last edited by 16 Jun 2017, 15:22

            @BuZz ... and you ask me? :D

            Bild Text

            T C 2 Replies Last reply 16 Jun 2017, 15:24 Reply Quote 0
            • T
              TMNTturtlguy @cyperghost
              last edited by 16 Jun 2017, 15:24

              @cyperghost @meleu

              That did it! Success....I am now back to running without getting the errors. @cyperghost your script does work well. I am going to upload the update to github. If you are willing it would be great for you to test. It is easy for you to delete the script after testing if you don't find it useful. Thanks for all the help. Will be interested to see how updates to ES will affect this.

              1 Reply Last reply Reply Quote 0
              • C
                cyperghost @cyperghost
                last edited by cyperghost 16 Jun 2017, 15:25

                @BuZz
                The problem is that you can't kill ES with killall command.
                It will return to bash prompt and you are not able to restart in graphical mode on your TV (via SSH yes that works)

                So I seem to kill the latest child process that forces ES to restart IF a es-restart is present in /tmp

                meleus script kills two pids... and then ES is gone like killall.

                Maybe now you understand my "EUREKA" ;)

                B 1 Reply Last reply 16 Jun 2017, 15:27 Reply Quote 0
                • B
                  BuZz administrators @cyperghost
                  last edited by 16 Jun 2017, 15:27

                  @cyperghost perhaps he accidently killed the parent bash script. Killing all ES processes or just one shouldn't make a difference. I'll test though.

                  To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                  1 Reply Last reply Reply Quote 0
                  • C
                    cyperghost
                    last edited by 16 Jun 2017, 15:28

                    @BuZz
                    Please test... maybe you understand my EUREKA today, okay?
                    This was really tricky

                    B 1 Reply Last reply 16 Jun 2017, 15:29 Reply Quote 0
                    • M
                      meleu
                      last edited by 16 Jun 2017, 15:29

                      @cyperghost @TMNTturtlguy
                      Some background I would like to share with you guys:

                      • when you type emulationstation in the shell, it executes /usr/bin/emulationstation

                      • the /usr/bin/emulationstation is a shell script that calls /opt/retropie/supplementary/emulationstation/emulationstation.sh.

                      • the /opt/retropie/supplementary/emulationstation/emulationstation.sh calls the /opt/retropie/supplementary/emulationstation/emulationstation and this is the real emulationstation binary.

                      • the /opt/retropie/supplementary/emulationstation/emulationstation.sh has a logic to restart ES, restart system and shutdown system based on the existence of some specific files in /tmp. The code of this script can be seen here.

                      • in my failed attempt to restart ES from commandline, I was trying create the /tmp/es-restart and kill only the ES binary. According to the emulationstation.sh it's enough to restart ES. But as we saw, my approach is killing the emulationstation.sh too, and that is what is "crashing".

                      I'll try something more concise this evening, but if @cyperghost has some free time now and would like to investigate more, my suggestion is to find a way to kill only that very specific binary: /opt/retropie/supplementary/emulationstation/emulationstation.

                      I used those metacharacters on my pkill regex to try to match some edge cases (like running a custom branch ES or launching ES with some parameter).

                      P.S.: now that I see @BuZz is aboard, I'm sure that the elegant solution is coming. :)

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      1 Reply Last reply Reply Quote 2
                      • B
                        BuZz administrators @cyperghost
                        last edited by BuZz 16 Jun 2017, 15:29

                        @cyperghost I think the problem is just the emulationstation.sh is being killed (which handles the restarting). Should be simple enough to avoid killing that. eg specifying the process name exactly rather than pattern matching.

                        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                        C 1 Reply Last reply 16 Jun 2017, 15:30 Reply Quote 0
                        • C
                          cyperghost @BuZz
                          last edited by cyperghost 16 Jun 2017, 15:30

                          @BuZz Please go on.... I think it is not as easy
                          Because I manually lauched /opt.../ emulationstation.sh and that did not workd.
                          @TMNTturtlguy discovered the /tmp thing today +1 for him

                          B 1 Reply Last reply 16 Jun 2017, 15:32 Reply Quote 1
                          • B
                            BuZz administrators @cyperghost
                            last edited by BuZz 16 Jun 2017, 15:32

                            @cyperghost It should be. I would guess at something like

                            touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
                            

                            should be fine.

                            To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                            1 Reply Last reply Reply Quote 1
                            • C
                              cyperghost
                              last edited by 16 Jun 2017, 15:32

                              let me test...

                              1 Reply Last reply Reply Quote 0
                              • B
                                BuZz administrators
                                last edited by BuZz 16 Jun 2017, 15:35

                                or to work with emulationstation running from any path. (eg with emulationstation-kids etc).

                                touch /tmp/es-restart; pkill -f "/emulationstation$"
                                

                                To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                C 1 Reply Last reply 16 Jun 2017, 15:43 Reply Quote 1
                                • C
                                  cyperghost
                                  last edited by cyperghost 16 Jun 2017, 15:36

                                  Works fine

                                  touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
                                  
                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    cyperghost @BuZz
                                    last edited by cyperghost 16 Jun 2017, 15:43

                                    @BuZz said in How to restart ES from a script?:

                                    pkill -f "/emulationstation$"

                                    That let's restart just 2 PIDs... Does not work!

                                    touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
                                    

                                    runs fine all 3 PIDs are up to date


                                    Man ... I even wrote use the tty1 outputs. So indeed the relauch script was killed

                                    B T 2 Replies Last reply 16 Jun 2017, 15:47 Reply Quote 0
                                    • B
                                      BuZz administrators @cyperghost
                                      last edited by 16 Jun 2017, 15:47

                                      @cyperghost said in How to restart ES from a script?:

                                      pkill -f "/emulationstation$"

                                      Worked here when I just tested.

                                      To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                      C 1 Reply Last reply 16 Jun 2017, 15:47 Reply Quote 1
                                      • C
                                        cyperghost @BuZz
                                        last edited by cyperghost 16 Jun 2017, 15:47

                                        @BuZz Wait I post output in a few minutes...

                                        pi@retropie:~ $ ls /tmp
                                        es-restart  omxplayerdbus.root  omxplayerdbus.root.pid
                                        pi@retropie:~ $ ps -a
                                          PID TTY          TIME CMD
                                          862 tty1     00:00:00 bash
                                          867 tty1     00:00:00 bash
                                          868 tty1     00:00:00 emulationstatio
                                          874 tty1     00:00:00 emulationstatio
                                          877 tty1     00:00:13 emulationstatio
                                          990 pts/0    00:00:00 ps
                                        

                                        The command pkill

                                        pi@retropie:~ $ pkill -f -e "/emulationstation$"
                                        emulationstatio killed (pid 868)
                                        emulationstatio killed (pid 877)
                                        

                                        check with ps -a

                                        pi@retropie:~ $ ps -a
                                          PID TTY          TIME CMD
                                          862 tty1     00:00:00 bash
                                          874 tty1     00:00:00 emulationstatio
                                         1001 tty1     00:00:08 emulationstatio
                                         1071 pts/0    00:00:00 ps
                                        

                                        worked now... sorry... but 2 PIDs alive
                                        If PID 874 in my current setup will be killed than ES is wrecked.

                                        Thank you

                                        B 1 Reply Last reply 16 Jun 2017, 15:51 Reply Quote 0
                                        • B
                                          BuZz administrators @cyperghost
                                          last edited by BuZz 16 Jun 2017, 15:51

                                          @cyperghost use ps -fa as you can't tell what they are from that. probably parent bash scripts (which is correct - they shouldn't be killed).

                                          To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                          1 Reply Last reply Reply Quote 1
                                          44 out of 111
                                          • First post
                                            44/111
                                            Last post

                                          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.

                                            This community forum collects and processes your personal information.
                                            consent.not_received