Code

Merge branch 'sh-pidfile'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 22 Oct 2006 16:32:58 +0000 (18:32 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 22 Oct 2006 16:32:58 +0000 (18:32 +0200)
src/collectd.c
src/collectd.conf.pod
src/collectd.pod

index 0d9c90fce19a5dd2fe1e222c8a61f3d07e63a67d..98b9a1623f77b8840e6dbf36dbd7cfa4c69b2f1e 100644 (file)
@@ -123,6 +123,8 @@ static void exit_usage (char *name)
                        "  General:\n"
                        "    -C <file>       Configuration file.\n"
                        "                    Default: "CONFIGFILE"\n"
+                       "    -P <file>       PID-file.\n"
+                       "                    Default: "PIDFILE"\n"
 #if COLLECT_DAEMON
                        "    -f              Don't fork to the background.\n"
 #endif
@@ -281,7 +283,7 @@ int main (int argc, char **argv)
        char *configfile = CONFIGFILE;
 #if COLLECT_DAEMON
        struct sigaction sigChldAction;
-       char *pidfile    = PIDFILE;
+       char *pidfile    = NULL;
        pid_t pid;
        int daemonize    = 1;
 #endif
@@ -305,7 +307,7 @@ int main (int argc, char **argv)
 
                c = getopt (argc, argv, "hC:"
 #if COLLECT_DAEMON
-                               "f"
+                               "fP:"
 #endif
                );
 
@@ -318,6 +320,9 @@ int main (int argc, char **argv)
                                configfile = optarg;
                                break;
 #if COLLECT_DAEMON
+                       case 'P':
+                               pidfile = optarg;
+                               break;
                        case 'f':
                                daemonize = 0;
                                break;
@@ -368,7 +373,8 @@ int main (int argc, char **argv)
        sigChldAction.sa_handler = SIG_IGN;
        sigaction (SIGCHLD, &sigChldAction, NULL);
 
-       if ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL)
+       if ((pidfile == NULL)
+                       && ((pidfile = cf_get_option ("PIDFile", PIDFILE)) == NULL))
        {
                fprintf (stderr, "Cannot obtain pidfile. This shoud not happen. Ever.");
                return (1);
index f3e2585659504f26af3d335bf37e0bacf659726d..7e4b858e84b09ad0db0a2fee0d7b225af3dd0a04 100644 (file)
@@ -49,7 +49,8 @@ will be mostly useless. The names of the plugins are listed in L<collectd(1)>.
 =item B<PIDFile> I<File>
 
 Sets where to write the PID file to. This file is overwritten when it exists
-and deleted when the program ist stopped. Available in B<all modes>.
+and deleted when the program ist stopped. Some init-scripts might override this
+setting using the B<-P> commandline option. Available in B<all modes>.
 
 =item B<DataDir> I<Directory>
 
index 26185eea444e63d6ab09f9ce6e74874a9534f50d..0e1adc50c6f1c3e9a9e772bab1458936cdf135f2 100644 (file)
@@ -110,6 +110,13 @@ Specify an alternative config file. This is the place to go when you wish to
 change B<collectd>'s behavior. The path may be relative to the current working
 directory.
 
+=item B<-P> I<E<lt>pid-fileE<gt>>
+
+Specify an alternative pid file. This overwrites any settings in the config 
+file. This is thought for init-scripts that require the PID-file in a certain
+directory to work correctly. For everyday-usage use the B<PIDFile>
+config-option.
+
 =item B<-f>
 
 Don't fork to the background. I<collectd> will also B<not> close standard file