From 96cfbbdf14ee6a4328b33d25d58604ffa5129d06 Mon Sep 17 00:00:00 2001 From: lars Date: Wed, 29 Nov 2006 13:46:06 +0000 Subject: [PATCH] improved error handling of the server start script --- bin/CryptoBoxWebserver | 18 ++++++++++-------- bin/cryptobox.conf | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/CryptoBoxWebserver b/bin/CryptoBoxWebserver index 73c094a..1ab91ff 100755 --- a/bin/CryptoBoxWebserver +++ b/bin/CryptoBoxWebserver @@ -89,11 +89,15 @@ def fork_to_background(): def close_open_files(): - """this is only necessary if we want to go into background""" + """this is only necessary if we want to go into background + we will only close stdin, stdout and stderr + """ import resource # Resource usage information. - maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] - if (maxfd == resource.RLIM_INFINITY): - maxfd = 1024 + ## use the following lines to close all open files (including the log file) + # maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] + # if (maxfd == resource.RLIM_INFINITY): + # maxfd = 1024 + maxfd = 2 for fd in range(0, maxfd): try: os.close(fd) @@ -160,14 +164,12 @@ if __name__ == "__main__": options = parseOptions() ## run the webserver as a daemon process if options.background: fork_to_background() - ## close open files to allow background execution - if options.background: close_open_files() ## write pid file write_pid_file(options.pidfile) - ## TODO: if we close the open files _after_ initialization, then we also close - ## the log out - we have to figure something out here ... ## initialize the webserver class (before forking to get some error messages) cbw = CryptoBoxWebserver(options) + ## close open files to allow background execution + if options.background: close_open_files() ## start the webserver try: cbw.start() diff --git a/bin/cryptobox.conf b/bin/cryptobox.conf index e69b6a4..1350a5a 100644 --- a/bin/cryptobox.conf +++ b/bin/cryptobox.conf @@ -75,7 +75,7 @@ Details = ./cryptobox.log Stylesheet = /cryptobox-misc/cryptobox.css # default language -Language = de +Languages = de, en [Programs]