summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-10-01 02:53:38 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-10-01 11:05:04 +0200
commitebf01a4f89dcaf4f91c410eaf09d07ee5b081ff0 (patch)
tree7920e5fa458382bb65d28052153aa4a9b60235b6
parent072e3101045ccba1311a7dd3427319f1f1a92f3f (diff)
downloadsamba-ebf01a4f89dcaf4f91c410eaf09d07ee5b081ff0.tar.gz
samba-ebf01a4f89dcaf4f91c410eaf09d07ee5b081ff0.tar.bz2
samba-ebf01a4f89dcaf4f91c410eaf09d07ee5b081ff0.zip
autobuild: Add --daemon option.
-rwxr-xr-xscript/autobuild.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/script/autobuild.py b/script/autobuild.py
index e7a20150af..40635439c2 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -246,6 +246,30 @@ def find_git_root():
return None
+def daemonize(logfile):
+ pid = os.fork()
+ if pid == 0: # Parent
+ os.setsid()
+ pid = os.fork()
+ if pid != 0: # Actual daemon
+ os._exit(0)
+ else: # Grandparent
+ os._exit(0)
+
+ import resource # Resource usage information.
+ maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
+ if maxfd == resource.RLIM_INFINITY:
+ maxfd = 1024 # Rough guess at maximum number of open file descriptors.
+ for fd in range(0, maxfd):
+ try:
+ os.close(fd)
+ except OSError:
+ pass
+ os.open(logfile, os.O_RDWR | os.O_CREAT)
+ os.dup2(0, 1)
+ os.dup2(0, 2)
+
+
def rebase_tree(url):
print("Rebasing on %s" % url)
run_cmd("git remote add -t master master %s" % url, show=True, dir=test_master)
@@ -295,6 +319,8 @@ parser.add_option("", "--retry", help="automatically retry if master changes",
default=False, action="store_true")
parser.add_option("", "--email", help="send email to the given address on failure",
type='str', default=None)
+parser.add_option("", "--daemon", help="daemonize after initial setup",
+ action="store_true")
def email_failure(status, failed_task, failed_tag, errstr):
@@ -347,6 +373,11 @@ except Exception, reason:
raise Exception("Unable to create %s : %s" % (testbase, reason))
cleanup_list.append(testbase)
+if options.daemon:
+ logfile = os.path.join(testbase, "log")
+ print "Forking into the background, writing progress to %s" % logfile
+ daemonize(logfile)
+
while True:
try:
run_cmd("rm -rf %s" % test_master)