def test_my_own_pid(self): my_pid = os.getpid() self.assertTrue(pid_exists(my_pid)) if not Platform.is_windows(): '''Test is currently not valid under windows, because of the way nosetests is implemented. The command is 'runpy.py', but the executable command line is ['d:\\devtools\\python27\\python.exe', 'D:\\devtools\\python27\\Scripts\\nosetests.exe', 'tests.core'] Removing until we can make an more accurate test ''' self.assertTrue(is_my_process(my_pid))
def start(self, foreground=False): log.info("Starting") pid = self.pid() if pid: if is_my_process(pid): log.error("Not starting, another instance is already running" " (using pidfile {0})".format(self.pidfile)) sys.exit(1) else: log.warn("pidfile doesn't contain the pid of an agent process." ' Starting normally') log.info("Pidfile: %s" % self.pidfile) if not foreground: self.daemonize() self.write_pidfile() self.run()
def start(self, foreground=False): log.info("Starting") pid = self.pid() if pid: # Check if the pid in the pidfile corresponds to a running process # and if psutil is installed, check if it's a sd-agent one if is_my_process(pid): log.error("Not starting, another instance is already running" " (using pidfile {0})".format(self.pidfile)) sys.exit(1) else: log.warn("pidfile doesn't contain the pid of an agent process." ' Starting normally') if not foreground: self.daemonize() self.write_pidfile() self.run()
def start(self, foreground=False): log.info("Starting") pid = self.pid() if pid: # Check if the pid in the pidfile corresponds to a running process # and if psutil is installed, check if it's a datadog-agent one if is_my_process(pid): log.error("Not starting, another instance is already running" " (using pidfile {0})".format(self.pidfile)) sys.exit(1) else: log.warn("pidfile doesn't contain the pid of an agent process." ' Starting normally') if not foreground: self.daemonize() self.write_pidfile() self.run()
def test_my_own_pid(self): my_pid = os.getpid() self.assertTrue(pid_exists(my_pid)) self.assertTrue(is_my_process(my_pid))
def test_existing_process(self): self.assertFalse(is_my_process(1))