How to restart ES from a script?
-
@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! -
@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.
-
@BuZz ... and you ask me? :D
-
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.
-
@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" ;)
-
@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.
-
@BuZz
Please test... maybe you understand my EUREKA today, okay?
This was really tricky -
@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 theemulationstation.sh
it's enough to restart ES. But as we saw, my approach is killing theemulationstation.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. :)
-
-
@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. -
@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 -
@cyperghost It should be. I would guess at something like
touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
should be fine.
-
let me test...
-
or to work with emulationstation running from any path. (eg with emulationstation-kids etc).
touch /tmp/es-restart; pkill -f "/emulationstation$"
-
Works fine
touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
-
@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
-
@cyperghost said in How to restart ES from a script?:
pkill -f "/emulationstation$"
Worked here when I just tested.
-
@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
-
@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). -
touch /tmp/es-restart; killall -e "/opt/retropie/supplementary/emulationstation/emulationstation"
runs fine all 3 PIDs are up to date
When i use this in my script, it runs the first time. The second time i try to run it, the script crashes with error "cant remove /tmp/es-restart
-
@BuZz
Thank you I will remember that command!
Very usefull :)
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.