Exemple #1
0
 static void Main(string[] args)
 {
     // parse the command line
     try
     {
         if (Environment.UserName.Equals("System", StringComparison.OrdinalIgnoreCase))
         {
             ServiceBase[] ServicesToRun;
             ServicesToRun = new ServiceBase[]
             {
                 new LogrotateService()
             };
             ServiceBase.Run(ServicesToRun);
         }
         else
         {
             Rotater rotater = new Rotater(args);
             rotater.Process();
         }
     }
     catch (Exception e)
     {
         Logging.LogException(e);
         Environment.Exit(1);
     }
 }
 void Init( object state )
 {
     try
     {
         this._genericConfigFile = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "logrotate.conf" );
         this.ParseSettings();
         this._rotater = new Rotater( this._args );
         this._timer = new Timer( this.Rotate, null, TimeSpan.FromSeconds( this._interval ),
             TimeSpan.FromSeconds( this._interval ) );
     }
     catch ( Exception ex )
     {
         EventLog.WriteEntry( this.GetBaseCause( ex ) );
     }
 }