[SCM] live-studio branch, master, updated. fae68ee5ca42c1a59ce1c185ada5e211f1291f6e

Chris Lamb lamby at debian.org
Sat Jul 31 00:18:04 UTC 2010


The following commit has been merged in the master branch:
commit fae68ee5ca42c1a59ce1c185ada5e211f1291f6e
Author: Chris Lamb <lamby at debian.org>
Date:   Fri Jul 30 20:16:24 2010 -0400

    python-daemon is really weird and I can't get it to stop failing horribly

diff --git a/debian/control b/debian/control
index bf7a8fb..d4903a4 100644
--- a/debian/control
+++ b/debian/control
@@ -25,8 +25,7 @@ Description: Debian Live - Web based front-end
 
 Package: live-studio-runner
 Architecture: all
-Depends: ${misc:Depends}, live-build, live-studio (= ${binary:Version}),
- python-daemon
+Depends: ${misc:Depends}, live-build, live-studio (= ${binary:Version})
 Description: Debian Live - Web based front-end (queue runner)
  live-studio is a web frontend to the Debian Live tools. It offers users of any
  operating system to customise, build and then download a Debian Live system
diff --git a/live_studio/build/management/commands/queue_runner.py b/live_studio/build/management/commands/queue_runner.py
index 2525a11..dcd9503 100644
--- a/live_studio/build/management/commands/queue_runner.py
+++ b/live_studio/build/management/commands/queue_runner.py
@@ -1,15 +1,12 @@
 import os
 import sys
 import time
-import daemon
 import shutil
 import logging
 import datetime
 import tempfile
 import subprocess
 
-from daemon import pidlockfile
-
 from django.conf import settings
 from django.core.management.base import NoArgsCommand, make_option
 
@@ -28,8 +25,39 @@ class Command(NoArgsCommand):
 
     def handle_noargs(self, **options):
         if options['pidfile']:
-            pidfile = pidlockfile.PIDLockFile(options['pidfile'])
-            daemon.DaemonContext(pidfile=pidfile).open()
+            try:
+                pid = os.fork()
+                if pid > 0:
+                    sys.exit(0) # Exit first parent.
+            except OSError, e:
+                print >>sys.stderr, "fork #1 failed: (%d) %s" % (e.errno, e.strerror)
+                sys.exit(1)
+
+            # Decouple from parent environment.
+            os.chdir('/')
+            os.umask(0)
+            os.setsid()
+
+            # Do second fork.
+            try:
+                pid = os.fork()
+                if pid > 0:
+                    sys.exit(0)
+            except OSError, e:
+                print >>sys.stderr, "fork #2 failed: (%d) %s" % (e.errno, e.strerror)
+                sys.exit(1)
+
+            # Redirect standard file descriptors.
+            si = open('/dev/null', 'r')
+            so = open('/dev/null', 'a+')
+            se = open('/dev/null', 'a+', 0)
+            os.dup2(si.fileno(), sys.stdin.fileno())
+            os.dup2(so.fileno(), sys.stdout.fileno())
+            os.dup2(se.fileno(), sys.stderr.fileno())
+
+            f = open(options['pidfile'], 'a+')
+            f.write(str(os.getpid()))
+            f.close()
 
         self.run(options)
 

-- 
live-studio



More information about the debian-live-changes mailing list