Пример #1
0
 static void comm_GotStartPublishMessage(object sender, WatchdogMessageEventArgs <StartPublishMessage> e)
 {
     if (e.msg.machineName == null || e.msg.machineName.Equals(WatchdogComm.GetMachineName()) == false)
     {
         return;                                                                                                          //not for us
     }
     Trace.WriteLine("Got Publish Start Command for: " + e.msg.publishName + " from " + e.msg.senderName);
     StartPublish(e.msg.publishName);
 }
Пример #2
0
        static void SendStatusMessage()
        {
            WatchdogStatusMessage msg = new WatchdogStatusMessage(WatchdogComm.GetMachineName(), "", "No Publish Active", WatchdogStatusMessage.StatusLevel.NotRunning, Publish.GetAllPublishNames(pubRoot));

            if (curPublish == null)
            {
                msg.curPublishName = "";
                msg.statusText     = "No Publish Active";
                msg.statusLevel    = WatchdogStatusMessage.StatusLevel.NotRunning;
            }
            else
            {
                msg.curPublishName = curPublish.name;
                if (curPublish.IsCommandRunning())
                {
                    if (curPublish.watchdogAutoRestart)
                    {
                        msg.statusText = "Running. (WD)";
                    }
                    else
                    {
                        msg.statusText = "Running.";
                    }
                }
                else
                {
                    msg.statusText = "Stopped.";
                }
                if (curPublish.IsCommandRunning())
                {
                    msg.statusLevel = WatchdogStatusMessage.StatusLevel.Running;
                }
                else
                {
                    msg.statusLevel = WatchdogStatusMessage.StatusLevel.Error;
                }
            }
            comm.SendMessage(msg);
        }
Пример #3
0
 static void curPublish_WatchdogReset(object sender, EventArgs e)
 {
     comm.SendMessage <StartStopPublishMessageReply>(new StartStopPublishMessageReply(WatchdogComm.GetMachineName(), curPublish.name, false, "WARNING: Watchdog reset publish: " + curPublish.name + " @ " + curPublish.lastWatchdogIntervention.ToString()));
 }
Пример #4
0
        static void StartPublish(string name)
        {
            //if we had an old publish, kill it.
            if (curPublish != null)
            {
                curPublish.Stop();
                curPublish.Dispose();
            }

            try
            {
                curPublish = Publish.Load(name, pubRoot);
            }
            catch (Exception ex)
            {
                comm.SendMessage <StartStopPublishMessageReply>(new StartStopPublishMessageReply(WatchdogComm.GetMachineName(), name, false, "Exception Loading Publish" + ex.Message));
                return;
            }
            PublishRunStatus status = new PublishRunStatus("Unknown Publish Error", false);

            try
            {
                status = curPublish.Start(pubRoot);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Exception Starting! " + ex.Message);
                comm.SendMessage <StartStopPublishMessageReply>(new StartStopPublishMessageReply(WatchdogComm.GetMachineName(), name, false, "Exception Loading Publish" + ex.Message));
                return;
            }
            Trace.WriteLine("Pub Status: " + status.text);
            curPublish.WatchdogReset += new EventHandler(curPublish_WatchdogReset);
            comm.SendMessage <StartStopPublishMessageReply>(new StartStopPublishMessageReply(WatchdogComm.GetMachineName(), curPublish.name, status.ok, status.text));
        }
Пример #5
0
 static void comm_GotStopPublishMessage(object sender, WatchdogMessageEventArgs <StopPublishMessage> e)
 {
     if (curPublish == null)
     {
         return;
     }
     if (e.msg.publishName.ToLower() != curPublish.name.ToLower())
     {
         return;
     }
     try
     {
         curPublish.Stop();
     }
     catch (Exception ex)
     {
         Trace.WriteLine("Exception Stopping! " + ex.Message);
         comm.SendMessage <StartStopPublishMessageReply>(new StartStopPublishMessageReply(WatchdogComm.GetMachineName(), e.msg.publishName, false, "Exception Stopping Publish" + ex.Message));
     }
     curPublish.WatchdogReset -= new EventHandler(curPublish_WatchdogReset);
 }
Пример #6
0
        public static void KillApp()
        {
            traceText.Flush();
            try
            {
                if (curPublish != null)
                {
                    curPublish.Stop();
                }
            }
            catch (Exception ex)
            {
                if (curPublish != null)
                {
                    comm.SendMessage <StartStopPublishMessageReply>(new StartStopPublishMessageReply(WatchdogComm.GetMachineName(), curPublish.name, false, "Exception Stopping Publish" + ex.Message));
                }
                Trace.WriteLine("Exception Stopping! " + ex.Message);
            }
            running = false;

            Thread.Sleep(3000);
            traceText.Flush();
            //Process.GetCurrentProcess().Kill();
        }
Пример #7
0
        static void comm_GotCommandMessage(object sender, WatchdogMessageEventArgs <CommandMessage> e)
        {
            if (!((e.msg.machineName.ToLower() == WatchdogComm.GetMachineName().ToLower()) || (e.msg.machineName == CommandMessage.ALLMACHINES)))
            {
                return;
            }

            Trace.WriteLine("Executing Command: " + e.msg.command.ToString());
            switch (e.msg.command)
            {
            case CommandMessage.WatchdogCommand.AddServiceRight:
                LocalSecurityPolicyManager.SetRight("labuser", LocalSecurityPolicyManager.ServiceRight);
                break;

            case CommandMessage.WatchdogCommand.EnableWatchdogAutoReset:
                if (curPublish != null)
                {
                    curPublish.watchdogAutoRestart = true; curPublish.Save(pubRoot);
                }
                break;

            case CommandMessage.WatchdogCommand.DisableWatchdogAutoReset:
                if (curPublish != null)
                {
                    curPublish.watchdogAutoRestart = false; curPublish.Save(pubRoot);
                }
                break;

            case CommandMessage.WatchdogCommand.Quit:
                KillApp();
                break;

            case CommandMessage.WatchdogCommand.StartRemoteDebugger:
                try
                {
                    Process[] p = Process.GetProcessesByName("msvsmon");
                    Trace.WriteLine("MSVSMONS : " + p.Length);
                    if (p.Length > 0)
                    {
                        foreach (Process mon in p)
                        {
                            mon.Kill();
                        }
                    }
                    Trace.WriteLine("Starting : " + pubRoot + "\\deployment\\debugger.bat");
                    ProcessStartInfo pi = new ProcessStartInfo(pubRoot + "\\deployment\\debugger.bat");
                    pi.WorkingDirectory = pubRoot + "\\deployment";
                    Process.Start(pi);
                }
                catch
                { }

                break;

            case CommandMessage.WatchdogCommand.RefreshPublishes:
                SendStatusMessage();
                break;

            case CommandMessage.WatchdogCommand.AutoDetectRunningPublish:
                if (curPublish == null)
                {
                    Publish autoP = AutodetectActivePublish();
                    if (autoP != null)
                    {
                        StartPublish(autoP.name);
                    }
                }
                break;
            }
        }