| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using RDIFramework.Utilities;
- using System;
- using System.Configuration;
- using System.IO;
- using Topshelf;
- namespace TimedUpload
- {
- class Program
- {
- private static string ServiceName = ConfigurationManager.AppSettings["ServiceName"];
- static void Main(string[] args)
- {
- log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
- try
- {
- HostFactory.Run(x =>
- {
- x.UseLog4Net();
- x.Service<ServiceRunner>();
- x.SetDescription(ServiceName);
- x.SetDisplayName(ServiceName);
- x.SetServiceName(ServiceName);
- x.EnablePauseAndContinue();
- });
- }
- catch (Exception ex)
- {
- log4net.ILog logger = log4net.LogManager.GetLogger(typeof(Program));
- logger.Error("服务启动失败:" + ex.Message, ex);
- }
-
- }
- }
- }
|