Make -P or --pidfile keep programs from running if already running.
This commit is contained in:
1 parent
3059085830
commit
e9ab3dbf6d
10 files changed
+140
-4
No files matched your search
@@ -117,6 +117,16 @@ the PID of the running process. If \fIpidfile\fR is not specified, or
|
||||
if it does not begin with \fB/\fR, then it is created in
|
||||
\fB@rundir@\fR.
|
||||
|
||||
.TP
|
||||
\fB-f\fR, \fB--force\fR
|
||||
By default, when \fB-P\fR or \fB--pidfile\fR is specified and the
|
||||
specified pidfile already exists and is locked by a running process,
|
||||
\fBcontroller\fR refuses to start. Specify \fB-f\fR or \fB--force\fR
|
||||
to cause it to instead overwrite the pidfile.
|
||||
|
||||
When \fB-P\fR or \fB--pidfile\fR is not specified, this option has no
|
||||
effect.
|
||||
|
||||
.TP
|
||||
\fB-D\fR, \fB--detach\fR
|
||||
Causes \fBcontroller\fR to detach itself from the foreground session and
|
||||
|
||||
@@ -133,6 +133,7 @@ main(int argc, char *argv[])
|
||||
fatal(0, "no active or passive switch connections");
|
||||
}
|
||||
|
||||
die_if_already_running();
|
||||
daemonize();
|
||||
|
||||
while (n_switches > 0 || n_listeners > 0) {
|
||||
@@ -231,6 +232,7 @@ parse_options(int argc, char *argv[])
|
||||
static struct option long_options[] = {
|
||||
{"detach", no_argument, 0, 'D'},
|
||||
{"pidfile", optional_argument, 0, 'P'},
|
||||
{"force", no_argument, 0, 'f'},
|
||||
{"hub", no_argument, 0, 'H'},
|
||||
{"noflow", no_argument, 0, 'n'},
|
||||
{"max-idle", required_argument, 0, OPT_MAX_IDLE},
|
||||
@@ -260,6 +262,10 @@ parse_options(int argc, char *argv[])
|
||||
set_pidfile(optarg);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
ignore_existing_pidfile();
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
learn_macs = false;
|
||||
break;
|
||||
@@ -314,6 +320,7 @@ usage(void)
|
||||
printf("\nOther options:\n"
|
||||
" -D, --detach run in background as daemon\n"
|
||||
" -P, --pidfile[=FILE] create pidfile (default: %s/controller.pid)\n"
|
||||
" -f, --force with -P, start even if already running\n"
|
||||
" -H, --hub act as hub instead of learning switch\n"
|
||||
" -n, --noflow pass traffic, but don't add flows\n"
|
||||
" --max-idle=SECS max idle time for new flows\n"
|
||||
|
||||
Reference in new issue
Block a user