#!/usr/bin/python
-# Copyright (c) 2009, 2010 Nicira Networks
+# Copyright (c) 2009, 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
"(use --help for help)\n" % ovs.util.PROGRAM_NAME)
sys.exit(1)
- ovs.daemon.die_if_already_running()
-
remote = args[0]
idl = ovs.db.idl.Idl(remote, "Open_vSwitch", monitor_uuid_schema_cb)
return chdir_;
}
-/* Normally, die_if_already_running() will terminate the program with a message
- * if a locked pidfile already exists. If this function is called,
- * die_if_already_running() will merely log a warning. */
+/* Normally, daemonize() or damonize_start() will terminate the program with a
+ * message if a locked pidfile already exists. If this function is called, an
+ * existing pidfile will be replaced, with a warning. */
void
ignore_existing_pidfile(void)
{
/* If a locked pidfile exists, issue a warning message and, unless
* ignore_existing_pidfile() has been called, terminate the program. */
-void
+static void
die_if_already_running(void)
{
pid_t pid;
/* Running in daemon process. */
}
+ die_if_already_running();
make_pidfile();
/* Make sure that the unixctl commands for vlog get registered in a
void daemonize(void);
void daemonize_start(void);
void daemonize_complete(void);
-void die_if_already_running(void);
void ignore_existing_pidfile(void);
void daemon_usage(void);
pid_t read_pidfile(const char *name);
parse_options(argc, argv, &file_name, &remotes, &unixctl_path,
&run_command);
- die_if_already_running();
daemonize_start();
error = ovsdb_file_open(file_name, false, &db, &file);
return _chdir
def ignore_existing_pidfile():
- """Normally, die_if_already_running() will terminate the program with a
- message if a locked pidfile already exists. If this function is called,
- die_if_already_running() will merely log a warning."""
+ """Normally, daemonize() or daemonize_start() will terminate the program
+ with a message if a locked pidfile already exists. If this function is
+ called, an existing pidfile will be replaced, with a warning."""
global _overwrite_pidfile
_overwrite_pidfile = True
global _monitor
_monitor = True
-def die_if_already_running():
+def _die_if_already_running():
"""If a locked pidfile exists, issue a warning message and, unless
ignore_existing_pidfile() has been called, terminate the program."""
if _pidfile is None:
_monitor_daemon(daemon_pid)
# Running in daemon process
+ _die_if_already_running()
_make_pidfile()
def daemonize_complete():
-# Copyright (c) 2010 Nicira Networks.
+# Copyright (c) 2010, 2011 Nicira Networks.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
% (ovs.util.PROGRAM_NAME, key))
sys.exit(1)
- ovs.daemon.die_if_already_running()
ovs.daemon.daemonize_start()
if bail:
sys.stderr.write("%s: exiting after daemonize_start() as requested\n"
bool done;
int error;
- die_if_already_running();
-
error = jsonrpc_pstream_open(argv[1], &pstream);
if (error) {
ovs_fatal(error, "could not listen on \"%s\"", argv[1]);
-# Copyright (c) 2009, 2010 Nicira Networks
+# Copyright (c) 2009, 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
return done
def do_listen(name):
- ovs.daemon.die_if_already_running()
-
error, pstream = ovs.stream.PassiveStream.open(name)
if error:
sys.stderr.write("could not listen on \"%s\": %s\n"
ovs_fatal(0, "no active or passive switch connections");
}
- die_if_already_running();
daemonize_start();
retval = unixctl_server_create(unixctl_path, &unixctl);
parse_options(argc, argv, &s);
signal(SIGPIPE, SIG_IGN);
- die_if_already_running();
daemonize_start();
/* Start listening for ovs-appctl requests. */
process_init();
ovsrec_init();
- die_if_already_running();
daemonize_start();
retval = unixctl_server_create(NULL, &unixctl);
process_init();
ovsrec_init();
- die_if_already_running();
daemonize_start();
retval = unixctl_server_create(NULL, &unixctl);
"(use --help for help)\n" % ovs.util.PROGRAM_NAME)
sys.exit(1)
- ovs.daemon.die_if_already_running()
-
remote = args[0]
idl = ovs.db.idl.Idl(remote, "Open_vSwitch", monitor_uuid_schema_cb)