Browse Source

Fix pascalcoin_daemon bug on Windows as a service

Now can be installed as a service on windows calling pascalcoin_daemon -i (or -u to uninstall)
Pascal Coin 4 years ago
parent
commit
4a61f1ee06
2 changed files with 29 additions and 2 deletions
  1. 10 2
      src/pascalcoin_daemon.lpi
  2. 19 0
      src/pascalcoin_daemon.pp

+ 10 - 2
src/pascalcoin_daemon.lpi

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="10"/>
+    <Version Value="11"/>
     <PathDelim Value="\"/>
     <General>
       <Flags>
@@ -25,10 +25,18 @@
     </PublishOptions>
     <RunParams>
       <local>
-        <FormatVersion Value="1"/>
         <CommandLineParams Value="-r"/>
         <Display Use="True" Value=""/>
       </local>
+      <FormatVersion Value="2"/>
+      <Modes Count="1">
+        <Mode0 Name="default">
+          <local>
+            <CommandLineParams Value="-r"/>
+            <Display Use="True" Value=""/>
+          </local>
+        </Mode0>
+      </Modes>
     </RunParams>
     <Units Count="1">
       <Unit0>

+ 19 - 0
src/pascalcoin_daemon.pp

@@ -11,11 +11,30 @@ uses
   Classes, daemonapp,
   UCrypto, upcdaemon;
 
+Type
+
+  { TDaemonMainLoop }
+
+  TDaemonMainLoop = Class
+  public
+    Class procedure DaemonMainLoop;
+  end;
+
+{ TDaemonMainLoop }
+
+class procedure TDaemonMainLoop.DaemonMainLoop;
+begin
+  while not Application.Terminated do begin
+    CheckSynchronize(10);
+  end;
+end;
 
 begin
   Application.Title:='PascalCoin Daemon application';
+  IsConsole:=False;
   RegisterDaemonClass(TPCDaemon);
   RegisterDaemonMapper(TPCDaemonMapper);
+  Application.GUIMainLoop:[email protected];
   TCrypto.InitCrypto;
   Application.Run;
 end.