Exemplo n.º 1
0
 def run_every_hour(self):
     """Run every hour."""
     self.logger.info('MyAppController hourly job started')
     start_process(command=[
         '/opt/myapp/current/bin/myapp-backup', '--non-interactive'
     ],
                   name='backup_myapp')
Exemplo n.º 2
0
        run_system_process(command=command, name='Make Check')

    elif args.makecheckdocs:
        logger.info('Running make checkdocs.')
        command = ['make', 'checkdocs']
        run_system_process(command=command, name='Make Checkdocs')

    elif args.makeciunittests:
        logger.info('Running make ci_unit_tests.')
        command = ['make', 'ci_unit_tests']
        run_system_process(command=command, name='Make CI Unit Tests')

    elif args.standalone:
        logger.info('Starting in standalone mode.')
        # Start the process without a cluster controller
        process = start_process(command, terminate_event=terminate_event)
        processes.append((process, process.name))

    elif args.start:
        logger.info('Starting in cluster mode.')
        # Start the process with a cluster controller
        process = start_cluster_controller(
            name='myapp_controller',
            controller=MyAppController,
            cluster_controller_started_event=cluster_controller_started_event,
            terminate_event=terminate_event)
        processes.append((process, process.name))

        timeout = time() + 30
        timeout_reached = False
        while not cluster_controller_started_event.is_set():
    # Initialise the global processes list used to monitor active processes.
    processes = []
    # Define the multiprocessing terminate event. When this event is set all processes will start to terminate.
    cluster_controller_started_event = multiprocessing.Event()
    terminate_event = multiprocessing.Event()

    hostname = os.uname()[1]
    etcd_discovery_node = os.environ.get('ETCD_DISCOVERY_NODE')
    etcd_uuid = os.environ.get('ETCD_UUID')

    if args.standalone:
        logger.info('Starting in standalone mode.')
        command = ['tail', '-f', '/dev/null']  # ToDo: Standalone command
        # Start the process without a cluster controller
        process = start_process(command,
                                name='etcd',
                                terminate_event=terminate_event)
        processes.append((process, process.name))

    elif args.bootstrap:
        command = [
            "/usr/bin/etcd", "--name", "bootstrap", "--data-dir", "/data",
            "--advertise-client-urls", f"http://{hostname}:4001",
            "--listen-client-urls", "http://0.0.0.0:4001",
            "--initial-advertise-peer-urls", f"http://{hostname}:2380",
            "--listen-peer-urls", "http://0.0.0.0:2380",
            "--initial-cluster-token", "etcd-cluster-1", "--initial-cluster",
            f"bootstrap=http://{hostname}:2380", "--initial-cluster-state",
            "new"
        ]
        logger.info('Starting Bootstrap node.')
Exemplo n.º 4
0
        run_system_process(command=command, name='Make Check')

    elif args.makecheckdocs:
        logger.info('Running make checkdocs.')
        command = ['make', 'checkdocs']
        run_system_process(command=command, name='Make Checkdocs')

    elif args.makeciunittests:
        logger.info('Running make ci_unit_tests.')
        command = ['make', 'ci_unit_tests']
        run_system_process(command=command, name='Make CI Unit Tests')

    elif args.standalone:
        logger.info('Starting in standalone mode.')
        # Start the process without a cluster controller
        process = start_process(command, terminate_event=terminate_event)
        processes.append((process, process.name))

    elif args.start:
        logger.info('Starting in cluster mode.')
        # Start the process with a cluster controller
        process = start_cluster_controller(
            name='myapp_controller',
            controller=MyAppController,
            cluster_controller_started_event=cluster_controller_started_event,
            terminate_event=terminate_event)
        processes.append((process, process.name))

        timeout = time() + 30
        timeout_reached = False
        while not cluster_controller_started_event.is_set():