def start(path, _test=False): """Start the readerd instance. """ tac_file = os.path.join(path, "readerd.tac") if not os.path.exists(tac_file): if not _test: sys.stderr.write("unable to locate {}, exiting\n".format(tac_file)) return 1 os.chdir(path) sys.path.insert(0, os.path.abspath(os.getcwd())) argv = [ "twistd", "--no_save", "--logfile=twistd.log", "--python=readerd.tac" ] sys.argv = argv if _test: # Do not try to start twistd during unittesting return 0 # Starting twistd from twisted.scripts import twistd sys.stdout.write("readerd process is starting\n") twistd.run()
def run_bitmaskd(app_name=None, exec_path=None): # TODO --- configure where to put the logs... (get --logfile, --logdir # from bitmaskctl for (index, arg) in enumerate(sys.argv): if arg == '--backend': flags.BACKEND = sys.argv[index + 1] elif arg == '--verbose' or arg == '-v': flags.VERBOSE = True if STANDALONE: flags.VERBOSE = True flags.APP_NAME = app_name flags.EXEC_PATH = exec_path args = [ '-y', join(here(core), "bitmaskd.tac"), '--logfile', getLogPath(), ] if platform.system() != 'Windows': args.extend(['--pidfile', pid, '--umask', '0022']) sys.argv[1:] = args print '[+] launching bitmaskd...' run()
def debug(options): '''Run the buildslave without forking in background.''' # Set buildslave name to be used in buildbot.tac. sys.buildslave_name = pave.getOption( options, 'debug', 'name', default_value=pave.getHostname()) argv = [ 'twistd', '--no_save', '--nodaemon', '--logfile=-', '--python=buildbot.tac', ] sys.argv = argv try: from setproctitle import setproctitle setproctitle # Shut up the linter. except ImportError: setproctitle = lambda t: None setproctitle('buildbot-slave') from twisted.scripts import twistd with pushd(pave.fs.join([pave.path.build, 'slave'])): twistd.run()
def start(opts, out=sys.stdout, err=sys.stderr): basedir = opts['basedir'] print >>out, "STARTING", quote_output(basedir) if not os.path.isdir(basedir): print >>err, "%s does not look like a directory at all" % quote_output(basedir) return 1 for fn in listdir_unicode(basedir): if fn.endswith(u".tac"): tac = str(fn) break else: print >>err, "%s does not look like a node directory (no .tac file)" % quote_output(basedir) return 1 if "client" in tac: nodetype = "client" elif "introducer" in tac: nodetype = "introducer" else: nodetype = "unknown (%s)" % tac args = ["twistd", "-y", tac] if opts["syslog"]: args.append("--syslog") elif nodetype in ("client", "introducer"): fileutil.make_dirs(os.path.join(basedir, "logs")) args.extend(["--logfile", os.path.join("logs", "twistd.log")]) if opts["profile"]: args.extend(["--profile=profiling_results.prof", "--savestats",]) # now we're committed os.chdir(basedir) from twisted.scripts import twistd sys.argv = args twistd.run()
def main(): """ Run the twisted reactor, overriding the twistd class with new args. Uses the configuration generated by pydbwfserver.configuration.DbwfserverConfig() to override the arguments that are passed to twisted.scripts.twistd. The DbwfserverConfig is hard-coded to pass the filename of server.py to twistd as an argument. See server.py for the code that is executed when twisted.scripts.twistd.run() is called. """ # Refer to global config var, necessary for twistd override global config # Always release the Python GIL when using the Antelope bindings os.environ["ANTELOPE_PYTHON_GILRELEASE"] = "1" # Set up the logging infrastructure logger = logging.getLogger("pydbwfserver") # Configure system with command-line flags and pf file values. config = configuration.DbwfserverConfig() sys.argv = config.configure() if config.verbose: logger.setLevel(logging.INFO) if config.debug: logger.setLevel(logging.DEBUG) logger.info("Start Server!") run()
def entrypoint(): import sys from os import path app = path.join(path.dirname(__file__),name) sys.argv.insert(1, app) sys.argv.insert(1, '-y') from twisted.scripts.twistd import run run()
def entrypoint(): import sys from os import path app = path.join(path.dirname(__file__), name) sys.argv.insert(1, app) sys.argv.insert(1, '-y') from twisted.scripts.twistd import run run()
def run_twistd(args1=None, args2=None): args = [sys.argv[0]] if args1 is not None: args.extend(args1) args.append("qwebirc") if args2 is not None: args.extend(args2) sys.argv = args run()
def main(): logging.basicConfig(level=logging.INFO) config = Config() Register(to_bytes('http://%s:%d' % (config.get('bind_address', '127.0.0.1'), config.getint('http_port', 6800))), config.get('register_path', '/scrapyd-cluster/worker'), hosts=config.get('zookeeper_hosts', '127.0.0.1:2181')) argv[1:1] = ['-n', '-y', join(dirname(scrapyd.__file__), 'txapp.py')] run()
def main(args): cmdLine = run.calcCommandline() places = run.mkconfig('boredbot-config') ctllib.add(places, 'boredbot', cmd=cmdLine[0], args=cmdLine[1:] + ['loop'], env=['SECRET_KEY='+os.environ['SECRET_KEY']]) ctllib.add(places, 'boredweb', cmd=cmdLine[0], args=cmdLine[1:] + ['gunicorn', '--bind', '0.0.0.0:8000', '-w', '4', 'boredbot_deploy.wsgi:app'], env=['SECRET_KEY='+os.environ['SECRET_KEY']]) sys.argv = ['twistd', '--nodaemon', 'ncolony', '--messages', places.messages, '--config', places.config] twistd.run()
def main(): from twisted.scripts.twistd import run from os.path import join, dirname from sys import argv argv[1:] = [ '-y', join(dirname(__file__), "tasker.tac"), '--pidfile', '/var/run/myapp.pid', '--logfile', '/var/run/myapp.log' ] run()
def spawn(opts, conf): """ Acts like twistd """ if opts.config is not None: os.environ["CALLSIGN_CONFIG_FILE"] = opts.config sys.argv[1:] = [ "-noy", sibpath(__file__, "callsign.tac"), "--pidfile", conf['pidfile'], "--logfile", conf['logfile'], ] twistd.run()
def run_with_twistd(options, application_name=''): from twisted.scripts.twistd import run opts = ['-l', '/dev/null'] if options: opts.extend(options) sys.argv[1:] = opts application = service.Application(application_name) service.loadApplication = lambda f, k, p=None: application run()
def run_twistd(args1=None, args2=None): from twisted.scripts.twistd import run args = [sys.argv[0]] if args1 is not None: args.extend(args1) args.append("qwebirc") if args2 is not None: args.extend(args2) sys.argv = args run()
def handle(self, *args, **kwargs): # pylint: disable=W0613 argv = [ '-y', os.path.join(os.path.dirname(application.__file__), "application.py"), ] if settings.COMMANDER_PID_FILE is None: argv.append('--nodaemon') else: argv.extend(['--pidfile', settings.COMMANDER_PID_FILE]) sys.argv[1:] = argv run()
def launch(config): sys.path.insert(0, os.path.abspath(os.getcwd())) argv = ["twistd", "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=setting.tac"] sys.argv = argv from twisted.scripts import twistd twistd.run()
def run_twisted_server(app, port): import sys try: import _preamble _preamble except ImportError: sys.exc_clear() sys.argv = ['runserver.py', 'web', '--port', str(port), '--wsgi', 'app.app'] from twisted.scripts.twistd import run run()
def spawn(opts, conf): """ Acts like twistd """ if opts.config is not None: os.environ["MINIDNS_CONFIG_FILE"] = opts.config sys.argv[1:] = [ "-oy", sibpath(__file__, "minidns.tac"), "--pidfile", conf['pidfile'], "--logfile", conf['logfile'], ] twistd.run()
def launch(config): sys.path.insert(0, os.path.abspath(os.getcwd())) argv = [ "twistd", "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=setting.tac" ] sys.argv = argv from twisted.scripts import twistd twistd.run()
def run_bitmaskd(): # TODO --- configure where to put the logs... (get --logfile, --logdir # from the bitmask_cli argv[1:] = [ "-y", join(dirname(bitmask_core.__file__), "bitmaskd.tac"), "--pidfile", "/tmp/bitmaskd.pid", "--logfile", "/tmp/bitmaskd.log", "--umask=0022", ] print "[+] launching bitmaskd..." run()
def execute(argv, options): args = [ sys.argv[0] ] if argv is not None: args.extend(argv) args.append('thor') if options is not None: args.extend(options) sys.argv = args # TODO Debug log message of application arguments from twisted.scripts.twistd import run; run() # End of application execution. The main thread will exit after the reactor dies # in the execute method we will fall through to this point __logAndShutdown()
def launchNoDaemon(config): os.chdir(config['basedir']) sys.path.insert(0, os.path.abspath(config['basedir'])) argv = ["twistd", "--no_save", '--nodaemon', "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac"] sys.argv = argv # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for # windows. from twisted.scripts import twistd twistd.run()
def run(self, options): basedir = options.basedir stderr = options.stderr for fn in os.listdir(basedir): if fn.endswith(".tac"): tac = fn break else: print >>stderr, "%s does not look like a node directory (no .tac file)" % basedir return 1 os.chdir(options.basedir) twistd_args = list(options.twistd_args) sys.argv[1:] = ["--no_save", "--python", tac] + twistd_args print >>stderr, "Launching Server..." twistd.run()
def run(self, options): basedir = options.basedir stderr = options.stderr for fn in os.listdir(basedir): if fn.endswith(".tac"): tac = fn break else: print >> stderr, "%s does not look like a node directory (no .tac file)" % basedir return 1 os.chdir(options.basedir) twistd_args = list(options.twistd_args) sys.argv[1:] = ["--no_save", "--python", tac] + twistd_args print >> stderr, "Launching Server..." twistd.run()
def launch(config): sys.path.insert(0, os.path.abspath(os.getcwd())) # see if we can launch the application without actually having to # spawn twistd, since spawning processes correctly is a real hassle # on windows. argv = ["twistd", "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac"] sys.argv = argv # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for # windows. from twisted.scripts import twistd twistd.run()
def run_bitmaskd(): # TODO --- configure where to put the logs... (get --logfile, --logdir # from the bitmask_cli for (index, arg) in enumerate(argv): if arg == '--backend': flags.BACKEND = argv[index + 1] argv[1:] = [ '-y', join(here(core), "bitmaskd.tac"), '--pidfile', '/tmp/bitmaskd.pid', '--logfile', '/tmp/bitmaskd.log', '--umask=0022', ] print '[+] launching bitmaskd...' run()
def run_server(): # maybe print version and exit args = parse_args() if args.version: print __version__ return # launch soledad server using twistd tac = os.path.join(here(server), 'server.tac') args = [ '--nodaemon', '--pidfile=', '--syslog', '--prefix=soledad-server', '--python=%s' % tac, ] sys.argv[1:] = args run()
def profile(self): ''' Run in profile mode, dumping results to file ''' import logging from twisted.scripts.twistd import run from twisted.internet import reactor def gracefull_shutdown(): ''' Profiler results are written to file on reactor stop ''' reactor.stop() reactor.callLater(10 * 60, gracefull_shutdown) # Pass through service arguments sys.argv += os.getenv('PYTHON_SERVICE_ARGUMENT', '').split() run()
def launch(nodaemon): sys.path.insert(0, os.path.abspath(os.getcwd())) # see if we can launch the application without actually having to # spawn twistd, since spawning processes correctly is a real hassle # on windows. from twisted.python.runtime import platformType from twisted.scripts.twistd import run argv = ["twistd", "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac"] if nodaemon: argv.extend(["--nodaemon"]) if platformType != 'win32': # windows doesn't use pidfile option. argv.extend(["--pidfile="]) sys.argv = argv run()
def setUp(self): """Start the rackd service.""" super(MAASClusterServiceFixture, self).setUp() self.useFixture( ClusterConfigurationFixture( cluster_uuid="adfd3977-f251-4f2c-8d61-745dbd690bf2", maas_url="http://0.0.0.0:5253/MAAS/", tftp_port=5255)) # Fork the process to have rackd run in its own process. twistd_pid = os.fork() if twistd_pid == 0: # Redirect all output to /dev/null redirect_to_devnull() # Add command line options to start twistd. sys.argv[1:] = ["--nodaemon", "--pidfile", "", "maas-rackd"] # Start twistd. try: twistd.run() except: traceback.print_exc() os._exit(2) finally: os._exit(0) else: # Add cleanup to stop the twistd service. self.addCleanup(self.stop_twistd, twistd_pid) # Check that the child process is still running after a few # seconds. This makes sure that everything started okay and it # is still running. time.sleep(2) try: os.kill(twistd_pid, 0) except OSError: # Not running. raise ServiceError( "Failed to start rackd. Check that another test is " "not running at the same time.")
def launch(nodaemon): sys.path.insert(0, os.path.abspath(os.getcwd())) # see if we can launch the application without actually having to # spawn twistd, since spawning processes correctly is a real hassle # on windows. from twisted.python.runtime import platformType from twisted.scripts.twistd import run argv = [ "twistd", "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac" ] if nodaemon: argv.extend(["--nodaemon"]) if platformType != 'win32': # windows doesn't use pidfile option. argv.extend(["--pidfile="]) sys.argv = argv run()
def launch(config): sys.path.insert(0, os.path.abspath(os.getcwd())) if os.path.exists("/usr/bin/make") and os.path.exists("Makefile.buildbot"): # Preferring the Makefile lets slave admins do useful things like set # up environment variables for the buildslave. cmd = "make -f Makefile.buildbot start" if not config['quiet']: print cmd os.system(cmd) else: # see if we can launch the application without actually having to # spawn twistd, since spawning processes correctly is a real hassle # on windows. argv = ["twistd", "--no_save", "--logfile=twistd.log", # windows doesn't use the same default "--python=buildbot.tac"] sys.argv = argv # this is copied from bin/twistd. twisted-2.0.0 through 2.4.0 use # _twistw.run . Twisted-2.5.0 and later use twistd.run, even for # windows. from twisted.scripts import twistd twistd.run()
load_configuration(sys.argv[1]) base_arguments = [] web_arguments = [] for argument in sys.argv[2:]: if ( argument.startswith('--pidfile') or argument.startswith('--nodaemon') ): base_arguments.append(argument) else: web_arguments.append(argument) sys.argv = ['twistd'] sys.argv.extend(base_arguments) sys.argv.extend([ 'web', '--class', 'chevah.github_hooks_server.server.resource', ]) sys.argv.extend(web_arguments) # Set up forwarding of stdlib logs to Twisted. logger = logging.getLogger() logger.setLevel(logging.DEBUG) handler = TwistedLogHandler() logger.addHandler(handler) # Start twistd. sys.exit(run())
def handle(self, port='8080', *args, **kwargs): self.stdout.write("Starting the processing service") sys.path.insert(0, os.path.abspath('./apps/serial/')) sys.argv = ['','-ny','apps/serial/shell.tac'] run()
def main(): argv[1:1] = ['-n', '-y', join(dirname(flowder.__file__), 'txapp.py')] run()
def run_simple(): from twisted.scripts.twistd import run run()
def main(): argv[1:1] = ['-y', join(dirname(daemon.__file__), 'tac.py')] run()
def main(): argv[1:1] = ['-n', '-y', join(dirname(project.__file__), 'app.py')] run()
def main(): # Use adhoc argument parsing because of twisted's twisted argument parsing. # Change the current directory to the directory of the script. os.chdir(SCRIPT_DIR) depot_tools = os.path.join(ROOT_DIR, 'depot_tools') if not os.path.isdir(depot_tools): error('You must put a copy of depot_tools in %s' % depot_tools) bot_password_file = os.path.normpath( os.path.join(BUILD_DIR, 'site_config', '.bot_password')) if not os.path.isfile(bot_password_file): error('You forgot to put the password at %s' % bot_password_file) if (os.path.exists(os.path.join(GetRoot(), 'b')) and os.path.exists(os.path.join(GetRoot(), 'c'))): SpawnSubdirBuildbotsIfNeeded() # Make sure the current python path is absolute. old_pythonpath = os.environ.get('PYTHONPATH', '') os.environ['PYTHONPATH'] = '' for path in old_pythonpath.split(os.pathsep): if path: os.environ['PYTHONPATH'] += os.path.abspath(path) + os.pathsep # Update the python path. python_path = [ os.path.join(BUILD_DIR, 'site_config'), os.path.join(BUILD_DIR, 'scripts'), os.path.join(BUILD_DIR, 'scripts', 'release'), os.path.join(BUILD_DIR, 'third_party'), os.path.join(ROOT_DIR, 'build_internal', 'site_config'), os.path.join(ROOT_DIR, 'build_internal', 'symsrc'), SCRIPT_DIR, # Include the current working directory by default. ] # Need to update sys.path prior to the following imports. sys.path = python_path + sys.path import slave.bootstrap import config_bootstrap active_slavename = chromium_utils.GetActiveSlavename() config_bootstrap.Master.active_slavename = active_slavename active_master = GetActiveMaster(slave.bootstrap, config_bootstrap, active_slavename) bb_ver, tw_ver = GetThirdPartyVersions(active_master) python_path.append(os.path.join(BUILD_DIR, 'third_party', bb_ver)) python_path.append(os.path.join(BUILD_DIR, 'third_party', tw_ver)) sys.path.extend(python_path[-2:]) os.environ['PYTHONPATH'] = (os.pathsep.join(python_path) + os.pathsep + os.environ['PYTHONPATH']) os.environ['CHROME_HEADLESS'] = '1' os.environ['PAGER'] = 'cat' # Platform-specific initialization. if sys.platform.startswith('win'): # list of all variables that we want to keep env_var = [ 'APPDATA', 'BUILDBOT_ARCHIVE_FORCE_SSH', 'CHROME_HEADLESS', 'CHROMIUM_BUILD', 'COMMONPROGRAMFILES', 'COMMONPROGRAMFILES(X86)', 'COMMONPROGRAMW6432', 'COMSPEC', 'COMPUTERNAME', 'DBUS_SESSION_BUS_ADDRESS', # TODO(maruel): Remove once everyone is on 2.7.5. 'DEPOT_TOOLS_PYTHON_275', 'DXSDK_DIR', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA', 'NUMBER_OF_PROCESSORS', 'OS', 'PATH', 'PATHEXT', 'PROCESSOR_ARCHITECTURE', 'PROCESSOR_ARCHITEW6432', 'PROCESSOR_IDENTIFIER', 'PROGRAMFILES', 'PROGRAMW6432', 'PYTHONPATH', 'SYSTEMDRIVE', 'SYSTEMROOT', 'TEMP', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'TMP', 'USERNAME', 'USERDOMAIN', 'USERPROFILE', 'VS100COMNTOOLS', 'VS110COMNTOOLS', 'WINDIR', ] remove_all_vars_except(os.environ, env_var) # Extend the env variables with the chrome-specific settings. slave_path = [ depot_tools, # Reuse the python executable used to start this script. os.path.dirname(sys.executable), os.path.join(os.environ['SYSTEMROOT'], 'system32'), os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), os.path.join(os.environ['SYSTEMDRIVE'], 'Program Files', '7-Zip'), ] # build_internal/tools contains tools we can't redistribute. tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') if os.path.isdir(tools): slave_path.append(os.path.abspath(tools)) os.environ['PATH'] = os.pathsep.join(slave_path) os.environ['LOGNAME'] = os.environ['USERNAME'] elif sys.platform in ('darwin', 'posix', 'linux2'): # list of all variables that we want to keep env_var = [ 'CCACHE_DIR', 'CHROME_ALLOCATOR', 'CHROME_HEADLESS', 'CHROME_VALGRIND_NUMCPUS', 'DISPLAY', 'DISTCC_DIR', 'HOME', 'HOSTNAME', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'LANG', 'LOGNAME', 'PAGER', 'PATH', 'PWD', 'PYTHONPATH', 'SHELL', 'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_TTY', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'USER', 'USERNAME', ] remove_all_vars_except(os.environ, env_var) slave_path = [ os.path.join(os.path.expanduser('~'), 'slavebin'), depot_tools, ] # Git on mac is installed from git-scm.com/download/mac if sys.platform == 'darwin' and os.path.isdir('/usr/local/git/bin'): slave_path.append('/usr/local/git/bin') slave_path += [ # Reuse the python executable used to start this script. os.path.dirname(sys.executable), '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin' ] os.environ['PATH'] = os.pathsep.join(slave_path) else: error('Platform %s is not implemented yet' % sys.platform) # This may be redundant, unless this is imported and main is called. UseBotoPath() # This envrionment is defined only when testing the slave on a dev machine. is_testing = 'TESTING_MASTER' in os.environ if not is_testing: # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set. FixSubversionConfig() HotPatchSlaveBuilder(is_testing) import twisted.scripts.twistd as twistd twistd.run() if needs_reboot: # Send the appropriate system shutdown command. Reboot()
# Copyright (C) 2008,2009,2010,2011,2012,2013 Contributor # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import os sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "lib", "python2.6")) import aquilon.worker.depends import aquilon.aqdb.depends from twisted.scripts import twistd from aquilon.twisted_patches import updated_application_run twistd._SomeApplicationRunner.run = updated_application_run twistd.run()
def main(): # Use adhoc argument parsing because of twisted's twisted argument parsing. # Change the current directory to the directory of the script. os.chdir(SCRIPT_DIR) depot_tools = os.path.join(ROOT_DIR, 'depot_tools') if not os.path.isdir(depot_tools): error('You must put a copy of depot_tools in %s' % depot_tools) bot_password_file = os.path.normpath( os.path.join(BUILD_DIR, 'site_config', '.bot_password')) if not os.path.isfile(bot_password_file): error('You forgot to put the password at %s' % bot_password_file) if SpawnSubdirBuildbotsIfNeeded(): # If subdir buildbots were used, don't spawn the root process. return # Make sure the current python path is absolute. old_pythonpath = os.environ.get('PYTHONPATH', '') os.environ['PYTHONPATH'] = '' for path in old_pythonpath.split(os.pathsep): if path: os.environ['PYTHONPATH'] += os.path.abspath(path) + os.pathsep # Update the python path. python_path = [ os.path.join(BUILD_DIR, 'site_config'), os.path.join(BUILD_DIR, 'scripts'), os.path.join(BUILD_DIR, 'scripts', 'release'), os.path.join(BUILD_DIR, 'third_party'), os.path.join(BUILD_DIR, 'third_party', 'requests_1_2_3'), os.path.join(ROOT_DIR, 'build_internal', 'site_config'), os.path.join(ROOT_DIR, 'build_internal', 'symsrc'), SCRIPT_DIR, # Include the current working directory by default. ] # Need to update sys.path prior to the following imports. sys.path = python_path + sys.path import slave.bootstrap import config_bootstrap active_slavename = chromium_utils.GetActiveSlavename() config_bootstrap.Master.active_slavename = active_slavename active_master = GetActiveMaster( slave.bootstrap, config_bootstrap, active_slavename) bb_ver, tw_ver = GetThirdPartyVersions(active_master) python_path.append(os.path.join(BUILD_DIR, 'third_party', bb_ver)) python_path.append(os.path.join(BUILD_DIR, 'third_party', tw_ver)) sys.path = python_path[-2:] + sys.path os.environ['PYTHONPATH'] = ( os.pathsep.join(python_path) + os.pathsep + os.environ['PYTHONPATH']) os.environ['CHROME_HEADLESS'] = '1' os.environ['PAGER'] = 'cat' # Platform-specific initialization. if sys.platform.startswith('win'): # list of all variables that we want to keep env_var = [ 'APPDATA', 'BUILDBOT_ARCHIVE_FORCE_SSH', 'CHROME_HEADLESS', 'CHROMIUM_BUILD', 'COMMONPROGRAMFILES', 'COMMONPROGRAMFILES(X86)', 'COMMONPROGRAMW6432', 'COMSPEC', 'COMPUTERNAME', 'DBUS_SESSION_BUS_ADDRESS', 'DEPOT_TOOLS_GIT_BLEEDING', # TODO(maruel): Remove once everyone is on 2.7.5. 'DEPOT_TOOLS_PYTHON_275', 'DXSDK_DIR', 'GIT_USER_AGENT', 'HOME', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA', 'NUMBER_OF_PROCESSORS', 'OS', 'PATH', 'PATHEXT', 'PROCESSOR_ARCHITECTURE', 'PROCESSOR_ARCHITEW6432', 'PROCESSOR_IDENTIFIER', 'PROGRAMFILES', 'PROGRAMW6432', 'PYTHONPATH', 'SYSTEMDRIVE', 'SYSTEMROOT', 'TEMP', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'TMP', 'USERNAME', 'USERDOMAIN', 'USERPROFILE', 'VS100COMNTOOLS', 'VS110COMNTOOLS', 'WINDIR', ] remove_all_vars_except(os.environ, env_var) # Extend the env variables with the chrome-specific settings. slave_path = [ depot_tools, # Reuse the python executable used to start this script. os.path.dirname(sys.executable), os.path.join(os.environ['SYSTEMROOT'], 'system32'), os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), # Use os.sep to make this absolute, not relative. os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files', '7-Zip'), # TODO(hinoka): Remove this when its no longer needed crbug.com/481695 os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'cmake', 'bin'), ] # build_internal/tools contains tools we can't redistribute. tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') if os.path.isdir(tools): slave_path.append(os.path.abspath(tools)) os.environ['PATH'] = os.pathsep.join(slave_path) os.environ['LOGNAME'] = os.environ['USERNAME'] elif sys.platform in ('darwin', 'posix', 'linux2'): # list of all variables that we want to keep env_var = [ 'CCACHE_DIR', 'CHROME_ALLOCATOR', 'CHROME_HEADLESS', 'CHROME_VALGRIND_NUMCPUS', 'DISPLAY', 'DISTCC_DIR', 'GIT_USER_AGENT', 'HOME', 'HOSTNAME', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'LANG', 'LOGNAME', 'PAGER', 'PATH', 'PWD', 'PYTHONPATH', 'SHELL', 'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_TTY', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'USER', 'USERNAME', ] remove_all_vars_except(os.environ, env_var) slave_path = [ os.path.join(os.path.expanduser('~'), 'slavebin'), depot_tools, ] # Git on mac is installed from git-scm.com/download/mac if sys.platform == 'darwin' and os.path.isdir('/usr/local/git/bin'): slave_path.append('/usr/local/git/bin') slave_path += [ # Reuse the python executable used to start this script. os.path.dirname(sys.executable), '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin' ] os.environ['PATH'] = os.pathsep.join(slave_path) else: error('Platform %s is not implemented yet' % sys.platform) git_exe = 'git' + ('.bat' if sys.platform.startswith('win') else '') try: git_version = subprocess.check_output([git_exe, '--version']) except (OSError, subprocess.CalledProcessError) as e: Log('WARNING: Could not get git version information: %r' % e) git_version = '?' os.environ.setdefault('GIT_USER_AGENT', '%s git/%s %s' % ( sys.platform, git_version.rstrip().split()[-1], socket.getfqdn())) # This may be redundant, unless this is imported and main is called. UseBotoPath() # This envrionment is defined only when testing the slave on a dev machine. is_testing = 'TESTING_MASTER' in os.environ HotPatchSlaveBuilder(is_testing) import twisted.scripts.twistd as twistd twistd.run() shutdown_file = os.path.join(os.path.dirname(__file__), 'shutdown.stamp') if os.path.isfile(shutdown_file): # If this slave is being shut down gracefully, don't reboot it. try: os.remove(shutdown_file) # Only disable reboot if the file can be removed. Otherwise, the slave # might get stuck offline after every build. global needs_reboot needs_reboot = False except OSError: Log('Could not delete graceful shutdown signal file %s' % shutdown_file) # Although prevent_reboot_file looks similar to shutdown_file above, it is not # the same as shutdown.stamp is actually used by Buildbot to shut down the # slave process, while ~/no_reboot prevents rebooting the slave machine. prevent_reboot_file = os.path.join(os.path.expanduser('~'), 'no_reboot') if needs_reboot: if not os.path.isfile(prevent_reboot_file): # Send the appropriate system shutdown command. Reboot() # This line should not be reached. else: Log('Reboot was prevented by %s. Please remove the file and reboot the ' 'slave manually to resume automatic reboots.' % prevent_reboot_file)
def runTac(file_name): sys.argv.append('-noy') sys.argv.append(file_name) run()
def main(): argv[1:] = ['-n', '-y', join(dirname(scrapyd.__file__), 'txapp.py')] print 'lll' run() print 'kkk'
def main(): # Use adhoc argument parsing because of twisted's twisted argument parsing. # Change the current directory to the directory of the script. os.chdir(SCRIPT_PATH) build_dir = os.path.dirname(SCRIPT_PATH) # Directory containing build/slave/run_slave.py root_dir = os.path.dirname(build_dir) depot_tools = os.path.join(root_dir, 'depot_tools') if not os.path.isdir(depot_tools): error('You must put a copy of depot_tools in %s' % depot_tools) bot_password_file = os.path.normpath( os.path.join(build_dir, 'site_config', '.bot_password')) if not os.path.isfile(bot_password_file): error('You forgot to put the password at %s' % bot_password_file) # Make sure the current python path is absolute. old_pythonpath = os.environ.get('PYTHONPATH', '') os.environ['PYTHONPATH'] = '' for path in old_pythonpath.split(os.pathsep): if path: os.environ['PYTHONPATH'] += os.path.abspath(path) + os.pathsep # Update the python path. python_path = [ os.path.join(build_dir, 'site_config'), os.path.join(build_dir, 'scripts'), os.path.join(build_dir, 'scripts', 'release'), os.path.join(build_dir, 'third_party'), os.path.join(root_dir, 'build_internal', 'site_config'), os.path.join(root_dir, 'build_internal', 'symsrc'), SCRIPT_PATH, # Include the current working directory by default. ] # Need to update sys.path prior to the following imports. sys.path = python_path + sys.path import slave.bootstrap import config_bootstrap active_slavename = chromium_utils.GetActiveSlavename() config_bootstrap.Master.active_slavename = active_slavename active_master = GetActiveMaster( slave.bootstrap, config_bootstrap, active_slavename) bb_ver, tw_ver = GetThirdPartyVersions(active_master) python_path.append(os.path.join(build_dir, 'third_party', bb_ver)) python_path.append(os.path.join(build_dir, 'third_party', tw_ver)) sys.path.extend(python_path[-2:]) os.environ['PYTHONPATH'] = ( os.pathsep.join(python_path) + os.pathsep + os.environ['PYTHONPATH']) os.environ['CHROME_HEADLESS'] = '1' os.environ['PAGER'] = 'cat' # Platform-specific initialization. if sys.platform.startswith('win'): # list of all variables that we want to keep env_var = [ 'APPDATA', 'BUILDBOT_ARCHIVE_FORCE_SSH', 'CHROME_HEADLESS', 'CHROMIUM_BUILD', 'COMSPEC', 'COMPUTERNAME', 'DXSDK_DIR', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA', 'NUMBER_OF_PROCESSORS', 'OS', 'PATH', 'PATHEXT', 'PROCESSOR_ARCHITECTURE', 'PROCESSOR_ARCHITEW6432', 'PROGRAMFILES', 'PROGRAMW6432', 'PYTHONPATH', 'SYSTEMDRIVE', 'SYSTEMROOT', 'TEMP', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'TMP', 'USERNAME', 'USERDOMAIN', 'USERPROFILE', 'VS100COMNTOOLS', 'WINDIR', ] remove_all_vars_except(os.environ, env_var) # Extend the env variables with the chrome-specific settings. slave_path = [ depot_tools, # Reuse the python executable used to start this script. os.path.dirname(sys.executable), os.path.join(os.environ['SYSTEMROOT'], 'system32'), os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), ] # build_internal/tools contains tools we can't redistribute. tools = os.path.join(root_dir, 'build_internal', 'tools') if os.path.isdir(tools): slave_path.append(os.path.abspath(tools)) os.environ['PATH'] = os.pathsep.join(slave_path) os.environ['LOGNAME'] = os.environ['USERNAME'] elif sys.platform in ('darwin', 'posix', 'linux2'): # list of all variables that we want to keep env_var = [ 'CCACHE_DIR', 'CHROME_ALLOCATOR', 'CHROME_HEADLESS', 'CHROME_VALGRIND_NUMCPUS', 'DISPLAY', 'DISTCC_DIR', 'HOME', 'HOSTNAME', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'LANG', 'LOGNAME', 'PAGER', 'PATH', 'PWD', 'PYTHONPATH', 'SHELL', 'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_TTY', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'USER', 'USERNAME', ] remove_all_vars_except(os.environ, env_var) slave_path = [ os.path.join(os.path.expanduser('~'), 'slavebin'), depot_tools, # Reuse the python executable used to start this script. os.path.dirname(sys.executable), '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin' ] os.environ['PATH'] = os.pathsep.join(slave_path) else: error('Platform %s is not implemented yet' % sys.platform) # This envrionment is defined only when testing the slave on a dev machine. is_testing = 'TESTING_MASTER' in os.environ if not is_testing: # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set. FixSubversionConfig() HotPatchSlaveBuilder(is_testing) import twisted.scripts.twistd as twistd twistd.run() if needs_reboot: # Send the appropriate system shutdown command. Reboot()
def main(): # Use adhoc argument parsing because of twisted's twisted argument parsing. # Change the current directory to the directory of the script. os.chdir(SCRIPT_DIR) depot_tools = os.path.join(ROOT_DIR, 'depot_tools') if not os.path.isdir(depot_tools): error('You must put a copy of depot_tools in %s' % depot_tools) bot_password_file = os.path.normpath( os.path.join(BUILD_DIR, 'site_config', '.bot_password')) if not os.path.isfile(bot_password_file): error('You forgot to put the password at %s' % bot_password_file) if (os.path.exists(os.path.join(GetRoot(), 'b')) and os.path.exists(os.path.join(GetRoot(), 'c'))): SpawnSubdirBuildbotsIfNeeded() # Make sure the current python path is absolute. old_pythonpath = os.environ.get('PYTHONPATH', '') os.environ['PYTHONPATH'] = '' for path in old_pythonpath.split(os.pathsep): if path: os.environ['PYTHONPATH'] += os.path.abspath(path) + os.pathsep # Update the python path. python_path = [ os.path.join(BUILD_DIR, 'site_config'), os.path.join(BUILD_DIR, 'scripts'), os.path.join(BUILD_DIR, 'scripts', 'release'), os.path.join(BUILD_DIR, 'third_party'), os.path.join(ROOT_DIR, 'build_internal', 'site_config'), os.path.join(ROOT_DIR, 'build_internal', 'symsrc'), SCRIPT_DIR, # Include the current working directory by default. ] # Need to update sys.path prior to the following imports. sys.path = python_path + sys.path import slave.bootstrap import config_bootstrap active_slavename = chromium_utils.GetActiveSlavename() config_bootstrap.Master.active_slavename = active_slavename active_master = GetActiveMaster( slave.bootstrap, config_bootstrap, active_slavename) bb_ver, tw_ver = GetThirdPartyVersions(active_master) python_path.append(os.path.join(BUILD_DIR, 'third_party', bb_ver)) python_path.append(os.path.join(BUILD_DIR, 'third_party', tw_ver)) sys.path.extend(python_path[-2:]) os.environ['PYTHONPATH'] = ( os.pathsep.join(python_path) + os.pathsep + os.environ['PYTHONPATH']) os.environ['CHROME_HEADLESS'] = '1' os.environ['PAGER'] = 'cat' # Platform-specific initialization. if sys.platform.startswith('win'): # list of all variables that we want to keep env_var = [ 'APPDATA', 'BUILDBOT_ARCHIVE_FORCE_SSH', 'CHROME_HEADLESS', 'CHROMIUM_BUILD', 'COMMONPROGRAMFILES', 'COMMONPROGRAMFILES(X86)', 'COMMONPROGRAMW6432', 'COMSPEC', 'COMPUTERNAME', 'DBUS_SESSION_BUS_ADDRESS', 'DEPOT_TOOLS_GIT_BLEEDING', # TODO(maruel): Remove once everyone is on 2.7.5. 'DEPOT_TOOLS_PYTHON_275', 'DXSDK_DIR', 'GIT_USER_AGENT', 'HOME', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA', 'NUMBER_OF_PROCESSORS', 'OS', 'PATH', 'PATHEXT', 'PROCESSOR_ARCHITECTURE', 'PROCESSOR_ARCHITEW6432', 'PROCESSOR_IDENTIFIER', 'PROGRAMFILES', 'PROGRAMW6432', 'PYTHONPATH', 'SYSTEMDRIVE', 'SYSTEMROOT', 'TEMP', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'TMP', 'USERNAME', 'USERDOMAIN', 'USERPROFILE', 'VS100COMNTOOLS', 'VS110COMNTOOLS', 'WINDIR', ] remove_all_vars_except(os.environ, env_var) # Extend the env variables with the chrome-specific settings. slave_path = [ depot_tools, # Reuse the python executable used to start this script. os.path.dirname(sys.executable), os.path.join(os.environ['SYSTEMROOT'], 'system32'), os.path.join(os.environ['SYSTEMROOT'], 'system32', 'WBEM'), # Use os.sep to make this absolute, not relative. os.path.join(os.environ['SYSTEMDRIVE'], os.sep, 'Program Files', '7-Zip'), ] # build_internal/tools contains tools we can't redistribute. tools = os.path.join(ROOT_DIR, 'build_internal', 'tools') if os.path.isdir(tools): slave_path.append(os.path.abspath(tools)) os.environ['PATH'] = os.pathsep.join(slave_path) os.environ['LOGNAME'] = os.environ['USERNAME'] elif sys.platform in ('darwin', 'posix', 'linux2'): # list of all variables that we want to keep env_var = [ 'CCACHE_DIR', 'CHROME_ALLOCATOR', 'CHROME_HEADLESS', 'CHROME_VALGRIND_NUMCPUS', 'DISPLAY', 'DISTCC_DIR', 'GIT_USER_AGENT', 'HOME', 'HOSTNAME', 'HTTP_PROXY', 'http_proxy', 'HTTPS_PROXY', 'LANG', 'LOGNAME', 'PAGER', 'PATH', 'PWD', 'PYTHONPATH', 'SHELL', 'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_TTY', 'TESTING_MASTER', 'TESTING_MASTER_HOST', 'TESTING_SLAVENAME', 'USER', 'USERNAME', ] remove_all_vars_except(os.environ, env_var) slave_path = [ os.path.join(os.path.expanduser('~'), 'slavebin'), depot_tools, ] # Git on mac is installed from git-scm.com/download/mac if sys.platform == 'darwin' and os.path.isdir('/usr/local/git/bin'): slave_path.append('/usr/local/git/bin') slave_path += [ # Reuse the python executable used to start this script. os.path.dirname(sys.executable), '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin' ] os.environ['PATH'] = os.pathsep.join(slave_path) else: error('Platform %s is not implemented yet' % sys.platform) git_exe = 'git' + ('.bat' if sys.platform.startswith('win') else '') try: git_version = subprocess.check_output([git_exe, '--version']) except (OSError, subprocess.CalledProcessError) as e: Log('WARNING: Could not get git version information: %r' % e) git_version = '?' os.environ.setdefault('GIT_USER_AGENT', '%s git/%s %s' % ( sys.platform, git_version.rstrip().split()[-1], socket.getfqdn())) # This may be redundant, unless this is imported and main is called. UseBotoPath() # This envrionment is defined only when testing the slave on a dev machine. is_testing = 'TESTING_MASTER' in os.environ if not is_testing: # Don't overwrite the ~/.subversion/config file when TESTING_MASTER is set. FixSubversionConfig() HotPatchSlaveBuilder(is_testing) import twisted.scripts.twistd as twistd twistd.run() shutdown_file = os.path.join(os.path.dirname(__file__), 'shutdown.stamp') if os.path.isfile(shutdown_file): # If this slave is being shut down gracefully, don't reboot it. try: os.remove(shutdown_file) # Only disable reboot if the file can be removed. Otherwise, the slave # might get stuck offline after every build. global needs_reboot needs_reboot = False except OSError: Log('Could not delete graceful shutdown signal file %s' % shutdown_file) if needs_reboot: # Send the appropriate system shutdown command. Reboot()
def main(): argv[1:1] = ['-n', '-y', join(dirname(scrapyd.__file__), 'txapp.py')] run()
def main(): # change the current directory to the directory of the script. os.chdir(sys.path[0]) # Make sure the current python path is absolute. paths = os.environ['PYTHONPATH'].split(os.pathsep) os.environ['PYTHONPATH'] = '' for path in paths: os.environ['PYTHONPATH'] += os.path.abspath(path) os.environ['PYTHONPATH'] += os.pathsep # Update the python path. parent_dir = os.path.abspath(os.path.pardir) chromium_buildbot_dir = os.path.join(parent_dir, os.path.pardir, os.path.pardir, 'third_party', 'chromium_buildbot') root = os.path.dirname(parent_dir) python_path = [ os.path.join(chromium_buildbot_dir, 'site_config'), os.path.join(chromium_buildbot_dir, 'scripts'), os.path.join(chromium_buildbot_dir, 'scripts', 'release'), os.path.join(chromium_buildbot_dir, 'third_party'), os.path.join(parent_dir), '.', # Include the current working directory by default. ] os.environ['PYTHONPATH'] += os.pathsep.join(python_path) print os.environ['PYTHONPATH'] # Add these in from of the PATH too. new_path = python_path new_path.extend(sys.path) sys.path = new_path os.environ['CHROME_HEADLESS'] = '1' os.environ['PAGER'] = 'cat' # Platform-specific initialization. if sys.platform.startswith('win'): # list of all variables that we want to keep env_var = [ 'APPDATA', 'BUILDBOT_ARCHIVE_FORCE_SSH', 'CHROME_HEADLESS', 'CHROMIUM_BUILD', 'COMSPEC', 'COMPUTERNAME', 'DXSDK_DIR', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA', 'NUMBER_OF_PROCESSORS', 'OS', 'PATH', 'PATHEXT', 'PROCESSOR_ARCHITECTURE', 'PROCESSOR_ARCHITEW6432', 'PROGRAMFILES', 'PROGRAMW6432', 'PYTHONPATH', 'SYSTEMDRIVE', 'SYSTEMROOT', 'TEMP', 'TMP', 'USERNAME', 'USERDOMAIN', 'USERPROFILE', 'VS100COMNTOOLS', 'WINDIR', ] remove_all_vars_except(os.environ, env_var) # extend the env variables with the chrome-specific settings. depot_tools = os.path.join(chromium_buildbot_dir, '..', 'depot_tools') # Reuse the python executable used to start this script. python = os.path.dirname(sys.executable) system32 = os.path.join(os.environ['SYSTEMROOT'], 'system32') wbem = os.path.join(system32, 'WBEM') slave_path = [depot_tools, python, system32, wbem] # build_internal/tools contains tools we can't redistribute. tools = os.path.join(chromium_buildbot_dir, '..', 'build_internal', 'tools') if os.path.isdir(tools): slave_path.append(os.path.abspath(tools)) os.environ['PATH'] = os.pathsep.join(slave_path) os.environ['LOGNAME'] = os.environ['USERNAME'] elif sys.platform in ('darwin', 'posix', 'linux2'): # list of all variables that we want to keep env_var = [ 'CCACHE_DIR', 'CHROME_ALLOCATOR', 'CHROME_HEADLESS', 'DISPLAY', 'DISTCC_DIR', 'HOME', 'HOSTNAME', 'LANG', 'LOGNAME', 'PAGER', 'PATH', 'PWD', 'PYTHONPATH', 'SHELL', 'SSH_AGENT_PID', 'SSH_AUTH_SOCK', 'SSH_CLIENT', 'SSH_CONNECTION', 'SSH_TTY', 'USER', 'USERNAME', ] remove_all_vars_except(os.environ, env_var) depot_tools = os.path.join(chromium_buildbot_dir, '..', 'depot_tools') slave_path = [ depot_tools, '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin' ] os.environ['PATH'] = os.pathsep.join(slave_path) elif sys.platform == 'cygwin': #TODO(maruel): Implement me. pass else: raise NotImplementedError('Unknown platform') # Run the slave. HotPatchSlaveBuilder() import twisted.scripts.twistd as twistd twistd.run()
#!C:\Users\xcpro\ve1\Scripts\python.exe # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. import os, sys try: import _preamble except ImportError: sys.exc_clear() sys.path.insert(0, os.path.abspath(os.getcwd())) from twisted.scripts.twistd import run run()
def setUp(self): """Start the regiond service.""" super(MAASRegionServiceFixture, self).setUp() # Force django DEBUG false. self.addCleanup(patch(settings, "DEBUG", False)) # Create a database in the PostgreSQL cluster for each database # connection configured in Django"s settings that points to the same # datadir. cluster = ClusterFixture("db", preserve=True) self.useFixture(cluster) for database in settings.DATABASES.values(): if database["HOST"] == cluster.datadir: cluster.createdb(database["NAME"]) # Setup the database for testing. This is so the database is isolated # only for this testing. self.setup_databases() self.addCleanup(self.teardown_databases) # Fork the process to have regiond run in its own process. twistd_pid = os.fork() if twistd_pid == 0: # Redirect all output to /dev/null redirect_to_devnull() # Add command line options to start twistd. sys.argv[1:] = [ "--nodaemon", "--pidfile", "", "maas-regiond", ] # Change the DEFAULT_PORT so it can run along side of the # development regiond. from maasserver import eventloop patch(eventloop, "DEFAULT_PORT", 5253) # Start twistd. try: twistd.run() except: traceback.print_exc() os._exit(2) finally: os._exit(0) else: # Add cleanup to stop the twistd service. self.addCleanup(self.stop_twistd, twistd_pid) # Check that the child process is still running after a few # seconds. This makes sure that everything started okay and it # is still running. time.sleep(2) try: os.kill(twistd_pid, 0) except OSError: # Not running. raise ServiceError( "Failed to start regiond. Check that another test is " "not running at the same time.")