• 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.8k 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.
  • B
    BuZz administrators @meleu
    last edited by 17 Jun 2017, 06:32

    @meleu why "/opt/retropie/supplementary/.*/emulationstation([^.]|$)" rather than "/opt/retropie/supplementary/.*/emulationstation$" ? A use case I have missed ?

    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

    M 1 Reply Last reply 17 Jun 2017, 09:06 Reply Quote 0
    • M
      meleu @BuZz
      last edited by 17 Jun 2017, 09:06

      @BuZz yep. If the user launch emulationstation with some --argument the regex ending with emulationstation$ don't match. :-)

      Example: emulationstation --debug

      • Useful topics
      • joystick-selection tool
      • rpie-art tool
      • achievements I made
      B 1 Reply Last reply 17 Jun 2017, 09:10 Reply Quote 1
      • B
        BuZz administrators @meleu
        last edited by 17 Jun 2017, 09:10

        @meleu aha. Thanks. Didn't consider that.

        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 17 Jun 2017, 17:17 Reply Quote 0
        • C
          cyperghost @BuZz
          last edited by cyperghost 17 Jun 2017, 17:17

          @BuZz @meleu
          Changes are registered to Restart ES via batch thread
          added meleu as "slight" updater

          This was easy - wasn't it? EUREKA

          For @TMNTturtlguy what the difference between mine and @BuZz @meleu script.

          1. They doing all the same: killing one specific process

          but

          The script of meleu and BuZz
          specifies to kill all emulationstation scripts which can found in path "/opt/retropie/supplementary/"

          Mine just kills the latest call of any emulationstation call. That's the reason why I wrote ... Keep care of future updates of ES

          The the kind of "specification" makes the difference.

          Annother tipp for you: Every command has a help section ... just write --help as parameter
          If the program manis installed you can get more detailed help by man [command] for ex. man ls

          T 1 Reply Last reply 17 Jun 2017, 18:08 Reply Quote 0
          • T
            TMNTturtlguy @cyperghost
            last edited by 17 Jun 2017, 18:08

            @cyperghost question for you,

            I am currently running the main branch EmulationStation updated from source. I have however run several different builds of emulationstation for testing out new updates of ES. As I am now running the main branch as updated from the setup script shouldn't I be running form /opt/supplementary/ ? Are you suggesting that because I have run the test branches when the main install of ES is killed by @BuZz and @meleu command another instance of ES from another location runs?

            1 Reply Last reply Reply Quote 0
            • M
              meleu
              last edited by 17 Jun 2017, 18:26

              @cyperghost

              The script of meleu and BuZz
              specifies to kill all emulationstation scripts which can found in path "/opt/retropie/supplementary/"

              This is not true. My last solution above kills only the "real" ES binary. Only one process. And don't do anything with the scripts.

              My solution is also able to kill/restart any of the ES mods we (I, @TMNTturtlguy and other guys) are testing. It's also able to kill emulationstation if it's launched with some --argument.

              I didn't analyze the solution proposed by @cyperghost to be able to give my opinion, but I'm pretty sure that my solution works pretty fine for what @TMNTturtlguy wants to do in the OP.

              • Useful topics
              • joystick-selection tool
              • rpie-art tool
              • achievements I made
              C 1 Reply Last reply 18 Jun 2017, 04:14 Reply Quote 1
              • C
                cyperghost @meleu
                last edited by cyperghost 18 Jun 2017, 04:14

                @meleu My friend this wasn`t to be intended as an offension. I wrote scripts but I ment binaries. As I wrote in my last posting..,,

                1. They doing all the same: killing one specific process

                I know it works and it is very save for future ES version what mine is not because mine just kills the last PID of ES and may by coincidence is the right one in future version. I think that are the correct conclusions.


                Just for understanding....
                This RegEx expression excludes the DOT . so no shell script would be killed.
                But if a second instance as binary is named "emulationstation-newversion" then the expression would also be true.

                And if there are running two processes from two binaries in the path /opt/retropie/supplementary/ ....

                1. emulationstation
                2. emulationstaten-debugging
                  then both will be killed or am I wrong?

                I'm not very common with regex expressions ... still learning this but they are the holy grale for string processing.

                1 Reply Last reply Reply Quote 0
                • T
                  TMNTturtlguy @meleu
                  last edited by 19 Jun 2017, 03:29

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

                  wazzup guys!

                  in front of my RetroPie it is a way easier! Here is my one liner to restart ES with no issues (at least it works fine here):

                  touch /tmp/es-restart && pkill -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)"
                  

                  Yes, the only difference is those / chars before and after .* in the regex. It's working fine thanks to this commit on RetroPie-Setup.

                  That one liner is able to restart ES even if the user is running a testing ES branch ( @TMNTturtlguy knows what I'm saying) and/or the user launched ES with some --arguments.

                  @TMNTturtlguy I hope it helps you.

                  Cheers!

                  @meleu @cyperghost I am back infront of my pi tonight and tied @meleu code as quoted here. This works much better as it lets me change es_systems, restarts and then i can go back into the retorpie menu and run my script again. However I still have issue when pressing start to go to the menu and then to either restart ES or shudown system. In both cases it just flashing my script and then restarts ES. The only way to get rid of this is to Kill the highest number ES and sudo touch and then sudo rm /tmp/es-restart

                  So I am trying to figure out why this won't work on my setup. So I went into .emulationstation and deleted all of the downloaded emulationstation files from testing. I then wen into /opt/restropie/supplementary/ and sudo rm -r all of the directories for all of the test ES builds I have worked on. A this point the only emulationstation directory in /opt/retropie/supplementary/ that exists is the main branch emulationstation. SO this should mean that the only es files i have are the standard build.

                  Re-ran @meleu script from above - same exact results, when you press start and go to the quit menu and select restart or shutdown, it flashes the script and restarts.

                  So i decided to retry @BuZz

                  touch /tmp/es-restart
                  pkill -f "/opt/retropie/supplementary/.*/emulationstation$"

                  This time the first time through it worked great. It did what it was supposed to do, i went to start and chose to restart system, it restarted the system! Great.....but nope, it only worked that time. system restarted, went to start, quite and boom flash of script and automatic restart of ES.

                  Here are my 2 take aways:
                  1 - what else do i need to remove so i can verify i only have the current main build of ES on my machine?
                  2- @cyperghost original script works - i am unclear on his warning "beware of updates to ES" does this mean it might stop working the next time we update ES? What it his code would cause this to happen"
                  3- my script might be better off with notes that tell the user to manually restart ES for the changes to take place.

                  Thank everyone

                  C M 3 Replies Last reply 19 Jun 2017, 06:08 Reply Quote 0
                  • C
                    cyperghost @TMNTturtlguy
                    last edited by cyperghost 19 Jun 2017, 06:08

                    2- @cyperghost original script works - i am unclear on his warning "beware of updates to ES" does this mean it might stop working the next time we update ES? What it his code would cause this to happen"

                    The kill process identifies highest PID number only of any process that is called emulationstation
                    On future updates it may happen that there a new processes established maybe a video overlay or audio layer and this can also be called by emulationstation. And if you terminate that process then nothing happens. Okay not true, music is stopping or video stops playing ... but no restart is initiated! That is the warning it may not work in future updates of ES.

                    But I do not understand why the different scripts do not work. The main difference is see, that I used a sleeptimer between touch and kill and manually remove es-restart in /tmp

                    But the scripts from @meleu and @BuZz also work in my configuration.

                    the pkill command offers a parameter for display output: pkill -e -f "/opt.....
                    So you see what PID was killed.

                    1 Reply Last reply Reply Quote 0
                    • M
                      meleu @TMNTturtlguy
                      last edited by meleu 19 Jun 2017, 08:58

                      @TMNTturtlguy looks like a problem on your script, because I tested my solution to restart ES using a script inside RetroPie Menu with only the command yo restart es and everything runs flawlessly several times in a row.

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      C 1 Reply Last reply 19 Jun 2017, 09:51 Reply Quote 1
                      • C
                        cyperghost @meleu
                        last edited by cyperghost 19 Jun 2017, 09:51

                        @meleu --- wrong ---
                        Sorry wrong issue

                        @TMNTturtlguy
                        But I also think that it has something to do with your script because all solutions posted by meleu, @BuZz and mine results in the same mechanism to kill one specific process.

                        Not more not less

                        1 Reply Last reply Reply Quote 0
                        • M
                          meleu @TMNTturtlguy
                          last edited by 19 Jun 2017, 11:03

                          @TMNTturtlguy @cyperghost prepare for another EUREKA moment. :-)

                          However I still have issue when pressing start to go to the menu and then to either restart ES or shudown system. In both cases it just flashing my script and then restarts ES. The only way to get rid of this is to Kill the highest number ES and sudo touch and then sudo rm /tmp/es-restart

                          That commit BuZz made on RetroPie-Setup was exactly to avoid this problem. But I think I've found the bug on your script...

                          Here is what is happening:

                          • before that commit, the scripts launched via RetroPie menu were executed as root. Therefore the touch /tmp/es-restart/ was creating a file owned by root.
                          • the emulationstation processes are all started by the pi user.
                          • one of those emulationstation processes is a script responsible to rm /tmp/es-restart at some point, but as the script is being executed by the pi user, it can't remove a file owned by root, i.e. it fails to remove /tmp/es-restart.
                          • emulationstation always restarts if there's a file named /tmp/es-restart, and as this file wasn't removed, emulationstation is always restarting on your tests.

                          What BuZz made in that commit was exactly make the scripts launched via RetroPie menu be executed by the pi user. But the @TMNTturtlguy 's script makes this fix ineffective because it's doing sudo touch /tmp/es-restart. This means that the /tmp/es-restart file will be owned by root and the problem I described above still happens.

                          Got it? :-)

                          By the way, @TMNTturtlguy I've submitted a PR to your little repository: https://github.com/TMNTturtleguy/change_es_systems/pull/1

                          • Useful topics
                          • joystick-selection tool
                          • rpie-art tool
                          • achievements I made
                          C T 2 Replies Last reply 19 Jun 2017, 11:11 Reply Quote 1
                          • C
                            cyperghost @meleu
                            last edited by cyperghost 19 Jun 2017, 11:11

                            @meleu .... So mine worked for him because I force remove es-restart via sudo

                            M 1 Reply Last reply 19 Jun 2017, 11:15 Reply Quote 0
                            • M
                              meleu @cyperghost
                              last edited by meleu 19 Jun 2017, 11:15

                              @cyperghost yep, but as you can see here in emulationstation.sh, removing the /tmp/es-restart shouldn't be a user's task.

                              That emulationstation.sh is the piece of code responsible to manage what happens with the user's choice on ES Quit menu (restart ES, quit ES, restart system, shutdown system).

                              • Useful topics
                              • joystick-selection tool
                              • rpie-art tool
                              • achievements I made
                              C 1 Reply Last reply 19 Jun 2017, 13:06 Reply Quote 0
                              • T
                                TMNTturtlguy @meleu
                                last edited by 19 Jun 2017, 11:32

                                @meleu thanks so much! Gotta get the kids to daycare, will test out in about 45 minutes.

                                1 Reply Last reply Reply Quote 0
                                • C
                                  cyperghost @meleu
                                  last edited by 19 Jun 2017, 13:06

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

                                  @cyperghost yep, but as you can see here in emulationstation.sh, removing the /tmp/es-restart shouldn't be a user's task.

                                  That emulationstation.sh is the piece of code responsible to manage what happens with the user's choice on ES Quit menu (restart ES, quit ES, restart system, shutdown system).

                                  EUREKA

                                  1 Reply Last reply Reply Quote 0
                                  • T
                                    TMNTturtlguy
                                    last edited by 19 Jun 2017, 13:17

                                    @meleu I merged your changes and loaded into my pi, the script fails t launch. I noticed a few things:

                                    • the menu dialog functions were not present
                                    • the script that was on github was not updated to reflect the permission changes per the retropie setup script changes. sudo needs to be added in front of the rm and cp commands now. I hadn't updated because that was the last working script using @cyperghost command.

                                    I took your modifications and merged them with the dialog text and the sudo commands and i still get the same issue. When i go to the start menu, select quit, and then any function i see a flash of script and a restart. This newer code does not seem to change anything.

                                    I have added a second branch, branch v2 to the github repository. github v2 If you and @cyperghost could look at the v2 script and possibly download it and try to run it from the retropie menu that would be great.

                                    Thank you both for your time and help.

                                    M C 2 Replies Last reply 19 Jun 2017, 13:22 Reply Quote 0
                                    • M
                                      meleu @TMNTturtlguy
                                      last edited by 19 Jun 2017, 13:22

                                      @TMNTturtlguy I will only have a chance to look at it tomorrow... But I'll try. Cheers!

                                      • Useful topics
                                      • joystick-selection tool
                                      • rpie-art tool
                                      • achievements I made
                                      T 1 Reply Last reply 19 Jun 2017, 13:30 Reply Quote 1
                                      • T
                                        TMNTturtlguy @meleu
                                        last edited by 19 Jun 2017, 13:30

                                        @meleu Not a problem! No rush, I appreciate all the help. Thanks

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

                                          @TMNTturtlguy I think first @meleu should take a look on your script. If there are still issues with it then I build a "restart binary" based on my script but that will analyze processes and kills always the right one ... so there are no future issue okay?

                                          But I think Master meleu finds an easy solution....

                                          T 1 Reply Last reply 19 Jun 2017, 17:17 Reply Quote 1
                                          94 out of 111
                                          • First post
                                            94/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