2

I've used the below script both with and without expect fork. It's purpose is to start a .exe file on start-up, and if it fails, to restart it. The mono application must be started by root/sudo to work.

What happens:

  • Application Starts and shows Listening to port 8888 in output log
  • Upstart goes into respawn and tries to restart the script despite it already being started
  • An error message per respawn attempt appears in the output log saying that the application is already running
  • After an hour or so, the application fails/stops, and respawn is not triggered

Here is my upstart script:

author "me"
description "hi"

start on local-filesystems
stop on shutdown

console log
respawn
respawn limit 2 5

env DIR=/home/danny
env PATH=/sbin:/usr/sbin:/usr/local/bin:/user/bin:/bin

expect fork
script
    set -x
    /usr/bin/mono /home/danny/path-to-my.exe
end script

Any/all help is appreciated. I'm a little stumped on this one.

  • Googling "ubuntu wine upstart respawn exe" gives me 4,000 results, and this question is near the top. That's... Depressing. – Daniel Brown Apr 10 '16 at 14:21
  • It looks like "teamviewer" may use wine and an upstart script -- May be worth looking at it's upstart script to see how it's implemented: http://askubuntu.com/questions/328519/why-teamviewer-keeps-running-in-the-background – Daniel Brown Apr 10 '16 at 14:23
  • This may be the solution: http://superuser.com/questions/769950/digital-ocean-ubuntu-run-servicestack-as-a-daemon – Daniel Brown Apr 10 '16 at 14:26

1 Answers1

0

since the file is an EXE it is likely that you need a different way of detecting if it is running due to the fact that EXEs are run through wine and so are different than the programs native to ubuntu

  • Is there a way to tell Upstart to use a different method to detect start/stop? A log file is generated that is written to every "X seconds" with a timestamp. If it sees no entry... I could trigger a respawn – Daniel Brown Apr 10 '16 at 00:38
  • I'm granting you the bounty -- if only because you're the only user nice enough to chip in any thoughts. – Daniel Brown Apr 13 '16 at 18:17