Process monitor service in Windows

0

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.

Ahmed Al Hafoudh

Posted 2011-11-04T09:37:35.123

Reputation: 101

Answers

1

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.");
            }
        }
    }

James

Posted 2011-11-04T09:37:35.123

Reputation: 1 185

I need something standalone. Not self developed. But it might work. I have my reasons. – Ahmed Al Hafoudh – 2011-11-04T21:18:02.917