title: Run web.py as daemon
body: <p>I have a simple web.py program to load data. In the server I don't want to install apache or any webserver.</p>
  
  <p>I try to put it as a background service with <a href="http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/" rel="noreferrer">http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/</a> </p>
  
  <p>And subclassing:
  (from <a href="http://www.jejik.com/files/examples/daemon.py" rel="noreferrer">http://www.jejik.com/files/examples/daemon.py</a>)</p>
  
  <pre><code>class Daemon:
      def start(self):
          """
          Start the daemon
          """
          ... PID CHECKS....
  
          # Start the daemon
          self.daemonize()
          self.run()
  #My code
  class WebService(Daemon):
          def run(self):
              app.run()
  
  if __name__ == "__main__":
      if DEBUG:
          app.run()
      else:
          service = WebService(os.path.join(DIR_ACTUAL,'ElAdministrador.pid'))
          if len(sys.argv) == 2:
              if 'start' == sys.argv[1]:
                  service.start()
              elif 'stop' == sys.argv[1]:
                  service.stop()
              elif 'restart' == sys.argv[1]:
                  service.restart()
              else:
                  print "Unknown command"
                  sys.exit(2)
              sys.exit(0)
          else:
              print "usage: %s start|stop|restart" % sys.argv[0]
              sys.exit(2)
  </code></pre>
  
  <p>However, the web.py software not load (ie: The service no listen)</p>
  
  <p>If I call it directly (ie: No using the daemon code) work fine.</p>