Linux standalone startup (alternative way)

Tutorials, tips and tricks.

Moderator: moderators

Linux standalone startup (alternative way)

Postby DemoFreak » Sat Oct 02, 2010 12:42 pm

Hi,

as I somehow managed it to kill the Subsonic server several times by accessing it via Flash player remotely, I wanted it to restart automatically.

Pragmatical solution: add the following line to /etc/crontab
Code: Select all
@reboot  yourusername  while /bin/true; do if ! pgrep -f '[j]ava.*subsonic' >/dev/null; then /usr/local/bin/subsonic/subsonic.sh --quiet; echo "Subsonic started..."|mail -s "Subsonic daemon (re)started" youremail@address.here; fi; sleep 15; done
The whole thingy has to be on one line, no line break allowed. Change the path to subsonic.sh, your email address and your username (the user account Subsonic should be running as) appropriately.

Pros:
    - no initscript needed
    - automatically starts Subsonic after reboot
    - automatically restarts Subsonic after crash
    - email notification about Subsonic restart
Cons:
    - unusual way for daemon start
    - you have to add all possible options on one line, that may be confusing as it get long enough
Of course you could get rid of the last point by creating a wrapper script, but we wanted to be pragmatic and not accurate, didn't we? :D

HTH,

/DemoFreak
DemoFreak
 
Posts: 3
Joined: Sat Oct 02, 2010 11:34 am

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest