Program.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using RDIFramework.Utilities;
  2. using System;
  3. using System.Configuration;
  4. using System.IO;
  5. using Topshelf;
  6. namespace TimedUpload
  7. {
  8. class Program
  9. {
  10. private static string ServiceName = ConfigurationManager.AppSettings["ServiceName"];
  11. static void Main(string[] args)
  12. {
  13. log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
  14. try
  15. {
  16. HostFactory.Run(x =>
  17. {
  18. x.UseLog4Net();
  19. x.Service<ServiceRunner>();
  20. x.SetDescription(ServiceName);
  21. x.SetDisplayName(ServiceName);
  22. x.SetServiceName(ServiceName);
  23. x.EnablePauseAndContinue();
  24. });
  25. }
  26. catch (Exception ex)
  27. {
  28. log4net.ILog logger = log4net.LogManager.GetLogger(typeof(Program));
  29. logger.Error("服务启动失败:" + ex.Message, ex);
  30. }
  31. }
  32. }
  33. }