diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2005-12-06 18:50:52 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2005-12-06 18:50:52 +0000 |
commit | 592d406208fb387fc14b5ec2663804d9f6a22a49 (patch) | |
tree | 5a263a9e5144956b18460f91a62880beaf9450fa /src/sbin | |
parent | ccc99edf650eb11671792245efeb812a76ab0fd1 (diff) | |
download | bcfg2-592d406208fb387fc14b5ec2663804d9f6a22a49.tar.gz bcfg2-592d406208fb387fc14b5ec2663804d9f6a22a49.tar.bz2 bcfg2-592d406208fb387fc14b5ec2663804d9f6a22a49.zip |
Re-add daemonize support to the server
Fix some pylint errors
Add better error handling for function calls
Add mesh-mode support for sshbase
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1612 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin')
-rw-r--r-- | src/sbin/Bcfg2Server | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sbin/Bcfg2Server b/src/sbin/Bcfg2Server index 8b2423355..d8e224369 100644 --- a/src/sbin/Bcfg2Server +++ b/src/sbin/Bcfg2Server @@ -17,6 +17,7 @@ from xmlrpclib import Fault from socket import gethostbyaddr, herror from lxml.etree import XML, Element, tostring from M2Crypto.SSL import SSLError +import os, sys def dgetopt(arglist, opt, vopt): '''parse options into a dictionary''' @@ -174,6 +175,23 @@ if __name__ == '__main__': ssetup = dgetopt(argv[1:], options, doptions) if not ssetup['configfile']: ssetup['configfile'] = '/etc/bcfg2.conf' + if ssetup['daemon']: + if os.fork() != 0: + os._exit(0) + os.setsid() # Create new session + pid = os.fork() + if pid != 0: + pidfile = open(ssetup['daemon'], "w") + pidfile.write("%i" % pid) + pidfile.close() + os._exit(0) + os.chdir("/") + os.umask(0) + null = open("/dev/null", "w+") + os.dup2(null.fileno(), sys.__stdin__.fileno()) + os.dup2(null.fileno(), sys.__stdout__.fileno()) + os.dup2(null.fileno(), sys.__stderr__.fileno()) + s = Bcfg2(ssetup) while not s.shut: try: |