def daemonize(self): """Drop into the background.""" # I am assumuing this throws if fork fails. pid = os.fork() # In the parent, return. if pid != 0: # self.nxnode_rfile.close() # self.nxnode_wfile.close() os.close(self.nxnode_commfd) # del(self.nxnode_rfile) # del(self.nxnode_wfile) # del(self.nxnode_commfd) nxlog.setup('nxserver-outer') nxlog.log(nxlog.LOG_INFO, "Forked child to take care of nxsession stuff") return False # Dissociate from the nxserver terminal os.setsid() # If we need to change signal behavior, do it here. # Close the stdio fds. os.close(0) os.close(1) os.close(2) self.input = self.nxnode_rfile self.output = self.nxnode_wfile # I'm not sure what to do here with self.nxnode_rfile and self.nxnode_wfile # Closing the fd is enough, but the file objects would linger on. del (self.nxnode_rfile) del (self.nxnode_wfile) del (self.nxnode_commfd) nxlog.setup('nxserver-inner') nxlog.log(nxlog.LOG_INFO, "Successfully forked, " "taking care of nxsession stuff\n") try: self._session_read_loop() except Exception: trace = traceback.format_exc() nxlog.log( nxlog.LOG_ERR, 'Going down because exception caught ' 'at the top level.') for line in trace.split('\n'): nxlog.log(nxlog.LOG_ERR, '%s' % line) return True
def daemonize(self): """Drop into the background.""" # I am assumuing this throws if fork fails. pid = os.fork() # In the parent, return. if pid != 0: # self.nxnode_rfile.close() # self.nxnode_wfile.close() os.close(self.nxnode_commfd) # del(self.nxnode_rfile) # del(self.nxnode_wfile) # del(self.nxnode_commfd) nxlog.setup('nxserver-outer') nxlog.log(nxlog.LOG_INFO, "Forked child to take care of nxsession stuff") return False # Dissociate from the nxserver terminal os.setsid() # If we need to change signal behavior, do it here. # Close the stdio fds. os.close(0) os.close(1) os.close(2) self.input = self.nxnode_rfile self.output = self.nxnode_wfile # I'm not sure what to do here with self.nxnode_rfile and self.nxnode_wfile # Closing the fd is enough, but the file objects would linger on. del(self.nxnode_rfile) del(self.nxnode_wfile) del(self.nxnode_commfd) nxlog.setup('nxserver-inner') nxlog.log(nxlog.LOG_INFO, "Successfully forked, " "taking care of nxsession stuff\n") try: self._session_read_loop() except Exception: trace = traceback.format_exc() nxlog.log(nxlog.LOG_ERR, 'Going down because exception caught ' 'at the top level.') for line in trace.split('\n'): nxlog.log(nxlog.LOG_ERR, '%s' % line) return True
# along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # Author: [email protected] (Stephen Shirley) """nxloadconfig module unit tests""" import copy import unittest import nxlog import nxloadconfig __author__ = '[email protected] (Stephen Shirley)' __copyright__ = 'Copyright 2007 Google Inc.' nxlog.setup("nxloadconfig_test") class NXLoadConifgUnitTest(unittest.TestCase): """Unit test for nxloadconfig module.""" def setUp(self): # Not actually needed for every test, but it handy to have. self.conf = nxloadconfig.conf self.orig_conf = copy.copy(self.conf) def tearDown(self): # Cleanup after ourselves. See note on setUp() nxloadconfig.copy = copy.copy(self.orig_conf) def testWhich(self): self.assertEquals('/bin/bash', nxloadconfig.which("bash"))
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # Author: [email protected] (Stephen Shirley) """nxloadconfig module unit tests""" import copy import unittest import nxlog import nxloadconfig __author__ = '[email protected] (Stephen Shirley)' __copyright__ = 'Copyright 2007 Google Inc.' nxlog.setup("nxloadconfig_test") class NXLoadConifgUnitTest(unittest.TestCase): """Unit test for nxloadconfig module.""" def setUp(self): # Not actually needed for every test, but it handy to have. self.conf = nxloadconfig.conf self.orig_conf = copy.copy(self.conf) def tearDown(self): # Cleanup after ourselves. See note on setUp() nxloadconfig.copy = copy.copy(self.orig_conf) def testWhich(self):
def testSetup(self): """Test calling external setup()""" nxlog.setup("nxlog_test")
def testSetup(self): """Test calling external setup()""" nxlog.setup('nxlog_test')