When maintaining a server what is the best way to ensure that a
service stays up. i.e. if it goes down how do you automatically detect
it and make sure it starts again?

Links to any good tutorials would be helpful.

Thanks.