Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            Log.Info("Service Starting");

            // Write unhandled exceptions to log.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            Log.Info("Stating service");

            try
            {
                Log.Info("Stating engine");
                engine = new Engine();

                Log.Info("Creating WCF host");
                host = new ServiceHost(typeof(CommunityServerWFCService));

                // start WebService
                Log.Info("Starting WCF host");
                host.Open();

            }
            catch (Exception ex)
            {
                Log.Fatal("Exception: " + ex.ToString());
                System.Environment.Exit(1);
            }

            Log.Info("Service started");
        }
Esempio n. 2
0
 protected override void OnStop()
 {
     if (host != null)
     {
         host.Close();
         host = null;
         engine = null;
     }
 }