Program.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Threading;
  3. namespace D3NsCore
  4. {
  5. internal class Program
  6. {
  7. private static void Main(string[] args)
  8. {
  9. Console.WriteLine("Starting...");
  10. var svc = new D3NsClient("project.db3");
  11. svc.Log += (sender, eventArgs) => Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} {(eventArgs.Level + "").PadRight(7)} -- {eventArgs.Log}");
  12. svc.Start();
  13. try
  14. {
  15. Console.Title = "Direct DDNS - " + svc.Domain;
  16. }
  17. catch
  18. {
  19. //Do nothing
  20. }
  21. Console.WriteLine("Started.");
  22. if (args.Length > 0 && args[0].ToLower() == "--no-enter")
  23. {
  24. Console.WriteLine($"To stop, kill me, process id:{System.Diagnostics.Process.GetCurrentProcess().Id}");
  25. while (true)
  26. {
  27. Thread.Sleep(1000);
  28. }
  29. }
  30. Console.WriteLine("Press ENTER to stop.");
  31. Console.ReadLine();
  32. Console.WriteLine("Stopping...");
  33. svc.Stop();
  34. Console.WriteLine();
  35. Console.Write("Stopped. Press ENTER to exit...");
  36. Console.ReadLine();
  37. }
  38. }
  39. }