Testing fix for freenas

This commit is contained in:
echel0n 2014-06-18 11:24:59 -07:00
parent 0ae8b5429b
commit da826d24d4
1 changed files with 17 additions and 34 deletions

View File

@ -91,41 +91,33 @@ def loadShowsFromDB():
sickbeard.showList.append(curShow) sickbeard.showList.append(curShow)
except Exception, e: except Exception, e:
logger.log( logger.log(
u"There was an error creating the show in " + sqlShow["location"] + ": " + str(e).decode('utf-8'), u"There was an error creating the show in " + sqlShow["location"] + ": " + str(e).decode('utf-8'),
logger.ERROR) logger.ERROR)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
# TODO: update the existing shows if the showlist has something in it # TODO: update the existing shows if the showlist has something in it
def daemonize(): def daemonize():
"""
Fork off as a daemon
"""
# pylint: disable=E1101
# Make a non-session-leader child process
try: try:
pid = os.fork() # @UndefinedVariable - only available in UNIX pid = os.fork()
if pid != 0: if pid > 0:
os._exit(0) sys.exit(0)
except OSError, e: except OSError:
sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror)) print "fork() failed"
sys.exit(1) sys.exit(1)
os.setsid() # unix os.chdir(sickbeard.PROG_DIR)
os.setsid()
# Make sure I can read my own files and shut out others # Make sure I can read my own files and shut out others
prev = os.umask(0) prev= os.umask(0)
os.umask(prev and int('077', 8)) os.umask(prev and int('077',8))
# Make the child a session-leader by detaching from the terminal
try: try:
pid = os.fork() # @UndefinedVariable - only available in UNIX pid = os.fork()
if pid != 0: if pid > 0:
os._exit(0) sys.exit(0)
except OSError, e: except OSError:
sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror)) print "fork() failed"
sys.exit(1) sys.exit(1)
# Write pid # Write pid
@ -139,17 +131,8 @@ def daemonize():
u"Unable to write PID file: " + sickbeard.PIDFILE + " Error: " + str(e.strerror) + " [" + str( u"Unable to write PID file: " + sickbeard.PIDFILE + " Error: " + str(e.strerror) + " [" + str(
e.errno) + "]") e.errno) + "]")
# Redirect all output dev_null = file('/dev/null', 'r')
sys.stdout.flush() os.dup2(dev_null.fileno(), sys.stdin.fileno())
sys.stderr.flush()
devnull = getattr(os, 'devnull', '/dev/null')
stdin = file(devnull, 'r')
stdout = file(devnull, 'a+')
stderr = file(devnull, 'a+')
os.dup2(stdin.fileno(), sys.stdin.fileno())
os.dup2(stdout.fileno(), sys.stdout.fileno())
os.dup2(stderr.fileno(), sys.stderr.fileno())
def main(): def main():
""" """