Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

How does one make sure a lunux system service is always running?

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
Home » Discuss » DU Groups » Computers & Internet » Open Source and Free Software Group Donate to DU
 
benburch Donating Member (1000+ posts) Send PM | Profile | Ignore Wed Mar-22-06 09:36 PM
Original message
How does one make sure a lunux system service is always running?
My icecast server crashes at inopportune times. Is there some linux mechanism that can ensure that a init.d started service is restarted if it crashes?
Refresh | 0 Recommendations Printer Friendly | Permalink | Reply | Top
TheBaldyMan Donating Member (1000+ posts) Send PM | Profile | Ignore Thu Mar-23-06 01:48 AM
Response to Original message
1. you could run a background shell script to check this
it would take up some system resources and you could start it as an init.d service, periodically it could check to see if the requested services had been halted. I don't know enough to say whether restarting would be a good idea as it may have crashed out for a reason and may result in it continually attempting to restart the service only for it to fail again. you could certaily use it to notify you of a particular service failure.

Try and figure out the reason for the frequent crashes first.
Printer Friendly | Permalink | Reply | Top
 
Lithos Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-06-06 12:55 AM
Response to Original message
2. setup a cron job
To run a script to check this...

There should be sample scripts out on the net though the gem of the idea isn't trying to directly check to see if a process has stopped, but to test the functionality of the app and stop/restart it if it generates an error.

You might start with shelldorado.com.
Printer Friendly | Permalink | Reply | Top
 
FormerDittoHead Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-06-06 01:07 PM
Response to Original message
3. Maybe Webmin has a service for icecast? - nope
Edited on Sat May-06-06 01:20 PM by FormerRushFan
scratch this - I checked up and down and webmin doesn't offer a monitor for icecast
Printer Friendly | Permalink | Reply | Top
 
bemildred Donating Member (1000+ posts) Send PM | Profile | Ignore Sat May-06-06 10:37 PM
Response to Original message
4. One possible answer:
respawn

The respawn action causes init to run the command that follows, and if the command finishes executing, to run it again. You're likely to see something similar to this line in your inittab file:

1:2345:respawn:/sbin/mingetty tty1

The getty programs provide login prompts. The preceding line is for the first virtual console (/dev/tty1), the one you see when you press ALT-F1 or CONTROL-ALT-F1. The respawn action brings the login prompt back after you log out.


http://www.linux.com/article.pl?sid=04/06/23/1734235

There are some variations on how init works, but getty is the classic case of something that needs to be restarted when it quits, so if you look into how your system handles that, you have a model for what you need. In any case, check out inittab. You can of course also roll your own startup program/script that will wait for your process and restart it when it exits.

Printer Friendly | Permalink | Reply | Top
 
qnr Donating Member (1000+ posts) Send PM | Profile | Ignore Fri Jun-02-06 09:05 PM
Response to Reply #4
5. Along the lines of the comment in your last paragraph, about rolling your
own startup script... watch is a useful command. For example, I start my IRC bot with this command (in this case, I happen to run the command from within the directory that holds the binary):

while : ; do ./PageSix ; sleep 30; done

Every 30 seconds, it checks to see if it is running - if it isn't, it restarts it.
Printer Friendly | Permalink | Reply | Top
 
bemildred Donating Member (1000+ posts) Send PM | Profile | Ignore Fri Jun-02-06 11:06 PM
Response to Reply #5
6. I would try to use a wait handler.
Edited on Fri Jun-02-06 11:11 PM by bemildred
I'm not dissing what you are doing, but when I can use an asynchronous handler instead of polling I prefer it. I'm too lazy to look up the syntax, and in any case it would depend on the shell, but you'd have a wait() or waitpid() and the wait handler would cause a restart.
Printer Friendly | Permalink | Reply | Top
 
qnr Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Jun-03-06 06:38 AM
Response to Reply #6
7. I do use them. However, in the case of ensuring a process is running, I
find watch to be very useful. That's what we like about the OS though... there are multiple ways of accomplishing almost any task.
Printer Friendly | Permalink | Reply | Top
 
bemildred Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Jun-03-06 09:13 AM
Response to Reply #7
8. Yes. It is good to have options. nt
Printer Friendly | Permalink | Reply | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Sun Dec 22nd 2024, 08:09 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » DU Groups » Computers & Internet » Open Source and Free Software Group Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC