Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need something that runs in the background as a service (Windows), watches defined process and when it crosses thresholds it restarts/stop/starts the process again? (similar functionality of rubygem called "god")

I have a network camera software that runs as a server, but it does not support running as a Windows service. It also stops responding once a day. When it does, I can see that memory drops below 10MB. Usually it is about 20-30MB in RAM.

share|improve this question

If you are familiar with C# you could try using a background worker to monitor the process and restart it when you get problems.

E.g. something similar I have (for a GUI app) looks like the below

private void startServer()
    {
        if (this.CancellationPending == true)
        {
            Console.WriteLine("Termination of {0} requested", thisServer.serverSettings.serverName);
            this.ReportProgress(100);
            this.Dispose(true);
        }
        else
        {
            try
            {
                thisServer.serverStatus = status.Starting;
                using (Process p = Process.Start(thisServer.serverStartInfo))
                {
                    thisServer.serverProc = p;
                    p.WaitForInputIdle(thisServer.serverSettings.startupDuration.Milliseconds);
                    thisServer.serverStatus = status.Running;

                    while (p.Responding)
                    {
                       // happy days
                    }

                    thisServer.serverStatus = status.Unknown;
                    try
                    {
                        p.Close();
                        thisServer.serverStatus = status.Offline;
                    }
                    catch 
                    {
                        try
                        {
                            p.Kill();
                            thisServer.serverStatus = status.Offline;
                        }
                        catch { }
                    }
                }

                reRun();
            }
            catch
            {
                thisServer.serverStatus = status.Offline;
                ReportProgress(100, "Error encountered when attempting to launch executable. Please review server settings.");
            }
        }
    }
share|improve this answer
    
I need something standalone. Not self developed. But it might work. I have my reasons. – Ahmed Al Hafoudh Nov 4 '11 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .