--- a/services/univention-ad-connector/modules/univention/connector/ad/main.py +++ a/services/univention-ad-connector/modules/univention/connector/ad/main.py @@ -53,6 +53,7 @@ parser.add_option( "--configbasename", dest="configbasename", help="", metavar="CONFIGBASENAME", default="connector") +parser.add_option('-n', '--no-daemon', dest='daemonize', default=True, action='store_false', help='Start process in foreground') (options, args) = parser.parse_args() CONFIGBASENAME = "connector" @@ -66,6 +67,12 @@ import mapping +def bind_stdout(): + if options.daemonize: + sys.stdout = open(STATUSLOGFILE, 'w+') + return sys.stdout + + def daemon(): try: pid = os.fork() @@ -107,9 +114,7 @@ def daemon(): def connect(): - - f = open(STATUSLOGFILE, 'w+') - sys.stdout = f + f = bind_stdout() print time.ctime() baseConfig = ConfigRegistry() @@ -225,8 +230,7 @@ def connect(): retry_rejected = 0 connected = True while connected: - f = open(STATUSLOGFILE, 'w+') - sys.stdout = f + f = bind_stdout() print time.ctime() # Aenderungen pollen sys.stdout.flush() @@ -285,8 +289,8 @@ def connect(): def main(): - - daemon() + if options.daemonize: + daemon() while True: try: @@ -294,8 +298,7 @@ def main(): except SystemExit: raise except: - f = open(STATUSLOGFILE, 'w+') - sys.stdout = f + f = bind_stdout() print time.ctime() text = ''