myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [2995] Fixed problems when executed as a daemon.


From: Giuseppe Scrivano
Subject: [myserver-commit] [2995] Fixed problems when executed as a daemon.
Date: Tue, 03 Feb 2009 17:25:49 +0000

Revision: 2995
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2995
Author:   gscrivano
Date:     2009-02-03 17:25:48 +0000 (Tue, 03 Feb 2009)

Log Message:
-----------
Fixed problems when executed as a daemon.

Modified Paths:
--------------
    trunk/myserver/binaries/myserver-daemon
    trunk/myserver/src/myserver.cpp

Modified: trunk/myserver/binaries/myserver-daemon
===================================================================
--- trunk/myserver/binaries/myserver-daemon     2009-02-02 20:47:19 UTC (rev 
2994)
+++ trunk/myserver/binaries/myserver-daemon     2009-02-03 17:25:48 UTC (rev 
2995)
@@ -1,5 +1,5 @@
 # MyServer
-# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
@@ -19,9 +19,8 @@
 #
 # This file should be placed in /etc/init.d
 #
-# please do a chmod a+x on the file
+# please do a chmod +x on the file
 #
-
 set -e
 
 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@@ -41,14 +40,14 @@
 d_start()
 {
        start-stop-daemon --start --pidfile $PIDFILE \
-       --exec $DAEMON -- -rSERVICE --logfile=$LOGFILE --pidfile=$PIDFILE
+       --exec $DAEMON -- -rSERVICE --log="file://$LOGFILE" --pidfile=$PIDFILE
 }
 
 
 d_stop()
 {
        start-stop-daemon --stop --pidfile $PIDFILE \
-       --exec $DAEMON -- -rSERVICE --logfile=$LOGFILE --pidfile=$PIDFILE
+       --exec $DAEMON -- -rSERVICE --log="file://$LOGFILE" --pidfile=$PIDFILE
 
 }
 
@@ -56,7 +55,7 @@
 d_reload()
 {
        start-stop-daemon --stop  --signal 1  --pidfile $PIDFILE \
-       --exec $DAEMON -- -rSERVICE --logfile=$LOGFILE --pidfile=$PIDFILE
+       --exec $DAEMON -- -rSERVICE --log="file://$LOGFILE" --pidfile=$PIDFILE
 }
 
 d_restart()

Modified: trunk/myserver/src/myserver.cpp
===================================================================
--- trunk/myserver/src/myserver.cpp     2009-02-02 20:47:19 UTC (rev 2994)
+++ trunk/myserver/src/myserver.cpp     2009-02-03 17:25:48 UTC (rev 2995)
@@ -1,6 +1,6 @@
 /*
 MyServer
-Copyright (C) 2002-2008 Free Software Foundation, Inc.
+Copyright (C) 2002-2009 Free Software Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -556,11 +556,6 @@
 #endif
 
 #ifdef ARGP
-
-#ifdef NOT_WIN
-  setpgid (0, 0);
-#endif
-
   if (input.useForkServer)
     Process::getForkServer ()->startForkServer ();
 #endif
@@ -594,38 +589,36 @@
           */
          if (pid < 0)
          {
-           return 1;
+          return 1;
          }
-         /*
-          *A good process id, return with success.
-          */
-         if (pid > 0)
-         {
-           return 0;
-         }
-         /*
-          *Store the PID.
-          */
+
+        if (pid)
+        {
+          /*
+           *Store the PID.
+           */
 #ifdef ARGP
-         if(input.pidFileName)
-           writePidfile(input.pidFileName);
-         else
-           writePidfile("/var/run/myserver.pid");
+          if(input.pidFileName)
+            writePidfile(input.pidFileName);
+          else
+            writePidfile("/var/run/myserver.pid");
 #else
-         writePidfile("/var/run/myserver.pid");
+          writePidfile("/var/run/myserver.pid");
 #endif
+          return 0;
+        }
+
          /*
           *Create a SID for the new process.
           */
-         sid = setsid();
+        sid = setsid();
 
          /*
           *Error in setting a new sid, return the error.
           */
-         if (sid < 0)
-         {
-           return 1;
-         }
+        if (sid < 0)
+          return 1;
+         
 
          /*
           *Finally run the server from the forked process.
@@ -645,7 +638,7 @@
     Process::getForkServer ()->killServer ();
 #endif
 
-   return 0;
+  return 0;
 }
 
 #ifndef WIN32






reply via email to

[Prev in Thread] Current Thread [Next in Thread]