1
0
mirror of https://bitbucket.org/anguist/ntpa synced 2025-10-06 02:51:23 +00:00
Files
ntpa/Ntp.Analyzer.Process/Main.cs

86 lines
2.6 KiB
C#
Raw Normal View History

2016-04-02 11:22:42 +02:00
//
// Main.cs
//
// Author:
// Carsten Sonne Larsen <cs@innolan.dk>
//
// Copyright (c) 2013-2016 Carsten Sonne Larsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
2016-04-16 14:19:42 +02:00
using System.IO;
2016-05-22 23:40:47 +02:00
using Ntp.Log;
2016-04-02 11:22:42 +02:00
using Ntp.Monitor.Server;
2016-04-16 14:19:42 +02:00
using Ntp.Process;
2016-04-02 11:22:42 +02:00
namespace Ntp.Analyzer.Process
{
public sealed class Main
{
2016-05-22 23:40:47 +02:00
public Main(string configFile, int pid, string pidFile, string name, LogGroup initlog)
2016-04-02 11:22:42 +02:00
{
this.configFile = configFile;
this.pid = pid;
2016-04-16 14:19:42 +02:00
this.pidFile = pidFile;
2016-04-02 11:22:42 +02:00
this.name = name;
2016-05-22 23:40:47 +02:00
this.initlog = initlog;
2016-04-02 11:22:42 +02:00
}
private readonly string configFile;
2016-05-22 23:40:47 +02:00
private readonly LogGroup initlog;
private readonly string name;
2016-04-02 11:22:42 +02:00
private readonly int pid;
2016-04-16 14:19:42 +02:00
private readonly string pidFile;
2016-04-02 11:22:42 +02:00
2016-05-22 23:40:47 +02:00
public void Run()
2016-04-02 11:22:42 +02:00
{
bool reload = true;
2016-05-22 23:40:47 +02:00
while (reload)
{
var i = new Initializer(configFile, pid, pidFile, name, initlog);
i.Run();
2016-04-02 11:22:42 +02:00
if (!i.Ready)
2016-05-27 20:41:11 +02:00
break;
2016-04-02 11:22:42 +02:00
2016-05-22 23:40:47 +02:00
var c = new Cluster(i.Scheduler, i.Controller, i.Nodes, i.Log);
c.Activate();
reload = i.Controller.Reload;
2016-04-02 11:22:42 +02:00
foreach (Listener l in i.Listeners)
2016-05-22 23:40:47 +02:00
l.Close();
2016-04-02 11:22:42 +02:00
2016-05-22 23:40:47 +02:00
LogFactory.Cleanup();
2016-04-02 11:22:42 +02:00
}
2016-04-16 14:19:42 +02:00
2016-05-22 23:40:47 +02:00
if (pidFile != null)
{
try
{
File.Delete(pidFile);
}
catch (Exception)
{
2016-04-16 14:19:42 +02:00
}
}
2016-04-02 11:22:42 +02:00
}
}
2016-03-05 15:25:01 +01:00
}