##// END OF EJS Templates
Minors fixes on Windows....
bgranger -
Show More
@@ -414,7 +414,7 b' class ApplicationWithClusterDir(Application):'
414 open_log_file = sys.stdout
414 open_log_file = sys.stdout
415 log.startLogging(open_log_file)
415 log.startLogging(open_log_file)
416
416
417 def write_pid_file(self):
417 def write_pid_file(self, overwrite=False):
418 """Create a .pid file in the pid_dir with my pid.
418 """Create a .pid file in the pid_dir with my pid.
419
419
420 This must be called after pre_construct, which sets `self.pid_dir`.
420 This must be called after pre_construct, which sets `self.pid_dir`.
@@ -423,9 +423,11 b' class ApplicationWithClusterDir(Application):'
423 pid_file = os.path.join(self.pid_dir, self.name + '.pid')
423 pid_file = os.path.join(self.pid_dir, self.name + '.pid')
424 if os.path.isfile(pid_file):
424 if os.path.isfile(pid_file):
425 pid = self.get_pid_from_file()
425 pid = self.get_pid_from_file()
426 raise PIDFileError(
426 if not overwrite:
427 'The pid file [%s] already exists. \nThis could mean that this '
427 raise PIDFileError(
428 'server is already running with [pid=%s].' % (pid_file, pid))
428 'The pid file [%s] already exists. \nThis could mean that this '
429 'server is already running with [pid=%s].' % (pid_file, pid)
430 )
429 with open(pid_file, 'w') as f:
431 with open(pid_file, 'w') as f:
430 self.log.info("Creating pid file: %s" % pid_file)
432 self.log.info("Creating pid file: %s" % pid_file)
431 f.write(repr(os.getpid())+'\n')
433 f.write(repr(os.getpid())+'\n')
@@ -442,7 +444,8 b' class ApplicationWithClusterDir(Application):'
442 self.log.info("Removing pid file: %s" % pid_file)
444 self.log.info("Removing pid file: %s" % pid_file)
443 os.remove(pid_file)
445 os.remove(pid_file)
444 except:
446 except:
445 pass
447 self.log.warn("Error removing the pid file: %s" % pid_file)
448 raise
446
449
447 def get_pid_from_file(self):
450 def get_pid_from_file(self):
448 """Get the pid from the pid file.
451 """Get the pid from the pid file.
@@ -20,7 +20,8 b' import os'
20 import signal
20 import signal
21 import sys
21 import sys
22
22
23 from twisted.scripts._twistd_unix import daemonize
23 if os.name=='posix':
24 from twisted.scripts._twistd_unix import daemonize
24
25
25 from IPython.core import release
26 from IPython.core import release
26 from IPython.external import argparse
27 from IPython.external import argparse
@@ -246,7 +246,7 b' class IPControllerApp(ApplicationWithClusterDir):'
246 def start_app(self):
246 def start_app(self):
247 # Start the controller service and set things running
247 # Start the controller service and set things running
248 self.main_service.startService()
248 self.main_service.startService()
249 self.write_pid_file()
249 self.write_pid_file(overwrite=True)
250 reactor.addSystemEventTrigger('during','shutdown', self.remove_pid_file)
250 reactor.addSystemEventTrigger('during','shutdown', self.remove_pid_file)
251 reactor.run()
251 reactor.run()
252
252
General Comments 0
You need to be logged in to leave comments. Login now