def fork_start_server(): """ Fork and start the server, returning a function which can be used to kill off the child. """ pid = os.fork() # If we are the parent, return if pid > 0: def dead_child(*args): print print "Failed to start server - "\ "is something else running on port 8000?" exit(4) signal.signal(signal.SIGCHLD, dead_child) # Give the server some time to start up time.sleep(2) def kill_child(): os.kill(pid, signal.SIGTERM) os.wait() atexit.register(kill_child) return # The autoreloader causes strange problems when forking, # so we won't use it here. argv[1] = '-R' cmdline.run() # Start the server
def setup_environment(): """ Setup a temporary environment, returning the directory name. """ # A temporary directory which will be destoryed when the script exists dir = tempdir() # Create the environment argv[0] = 'pyols' argv.extend(['-c', dir]) try: cmdline.run() except SystemExit: pass return dir
#!/usr/bin/env python """ This script is only to make it simple to get up-and-running with pyOLS. It is recomended that pyOLS is run using the instructions in README.txt. """ from pyols import cmdline cmdline.run()