Example #1
0
    def create_config(self):
        # creating the installation script
        self._logger.debug(
            'Rendering configuration script "{0}" from template'.format(
                self.config_path))
        utils.render_template_to_file(
            template_path='pm/nssm/nssm.conf.template',
            file_path=self.config_path,
            queue=self.queue,
            nssm_path=self.nssm_path,
            log_level=self.log_level.upper(),
            log_dir=self.log_dir,
            workdir=self.workdir,
            user=self.user,
            rest_host=self.rest_host,
            rest_port=self.rest_port,
            local_rest_cert_file=self.local_rest_cert_file,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            name=self.name,
            custom_environment=self._create_env_string(),
            executable_temp_path=self.executable_temp_path,
            startup_policy=self.startup_policy,
            failure_reset_timeout=self.failure_reset_timeout,
            failure_restart_delay=self.failure_restart_delay,
            storage_dir=utils.internal.get_storage_directory(self.user),
        )

        self._logger.debug('Rendered configuration script: {0}'.format(
            self.config_path))

        # run the configuration script
        self._logger.info('Running configuration script')
        self._runner.run(self.config_path)
        self._logger.debug('Successfully executed configuration script')
Example #2
0
    def create_enable_cron_script(self):

        enable_cron_script = os.path.join(
            self.workdir, '{0}-enable-cron.sh'.format(self.name))

        cron_respawn_path = os.path.join(
            self.workdir, '{0}-respawn.sh'.format(self.name))

        self._logger.debug('Rendering respawn script from template')
        utils.render_template_to_file(
            template_path='respawn.sh.template',
            file_path=cron_respawn_path,
            start_command=self.start_command(),
            status_command=self.status_command()
        )
        self._runner.run('chmod +x {0}'.format(cron_respawn_path))
        self._logger.debug('Rendering enable cron script from template')
        utils.render_template_to_file(
            template_path='crontab/enable.sh.template',
            file_path=enable_cron_script,
            cron_respawn_delay=self.cron_respawn_delay,
            cron_respawn_path=cron_respawn_path,
            user=self.user,
            workdir=self.workdir,
            name=self.name
        )
        self._runner.run('chmod +x {0}'.format(enable_cron_script))
        return enable_cron_script
Example #3
0
    def create_enable_cron_script(self):

        enable_cron_script = os.path.join(
            self.workdir, '{0}-enable-cron.sh'.format(self.name))

        cron_respawn_path = os.path.join(self.workdir,
                                         '{0}-respawn.sh'.format(self.name))

        self._logger.debug('Rendering respawn script from template')
        utils.render_template_to_file(template_path='respawn.sh.template',
                                      file_path=cron_respawn_path,
                                      start_command=self.start_command(),
                                      status_command=self.status_command())
        self._runner.run('chmod +x {0}'.format(cron_respawn_path))
        self._logger.debug('Rendering enable cron script from template')
        utils.render_template_to_file(
            template_path='crontab/enable.sh.template',
            file_path=enable_cron_script,
            cron_respawn_delay=self.cron_respawn_delay,
            cron_respawn_path=cron_respawn_path,
            user=self.user,
            workdir=self.workdir,
            name=self.name)
        self._runner.run('chmod +x {0}'.format(enable_cron_script))
        return enable_cron_script
Example #4
0
    def create_config(self):
        # creating the installation script
        self._logger.info(
            'Rendering configuration script "{0}" from template'.format(
                self.config_path))
        utils.render_template_to_file(
            template_path='pm/nssm/nssm.conf.template',
            file_path=self.config_path,
            queue=self.queue,
            nssm_path=self.nssm_path,
            log_level=self.log_level.upper(),
            log_dir=self.log_dir,
            log_max_bytes=self.log_max_bytes,
            log_max_history=self.log_max_history,
            workdir=self.workdir,
            user=self.user,
            service_user=self.service_user,
            service_password=self.service_password,
            rest_host=self.rest_host,
            rest_port=self.rest_port,
            local_rest_cert_file=self.local_rest_cert_file,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            name=self.name,
            custom_environment=self._create_env_string(),
            executable_temp_path=self.executable_temp_path,
            startup_policy=self.startup_policy,
            failure_reset_timeout=self.failure_reset_timeout,
            failure_restart_delay=self.failure_restart_delay,
            storage_dir=utils.internal.get_storage_directory(self.user),
        )

        self._logger.info('Rendered configuration script: {0}'.format(
            self.config_path))

        # run the configuration script
        self._logger.info('Running configuration script')
        try:
            result = self._runner.run([
                'powershell.exe',
                '-ExecutionPolicy',
                'bypass',
                '-File',
                self.config_path,
            ])
            self._logger.info(result.std_out.strip())
            self._logger.warning(result.std_err.strip())
        except Exception:
            # Log the exception here, then re-raise it. This is done in order
            # to ensure that the full exception message is shown.
            self._logger.exception("Failure encountered while running "
                                   "configuration script")
            raise
        self._logger.info('Successfully executed configuration script')
Example #5
0
    def create_disable_cron_script(self):

        disable_cron_script = os.path.join(
            self.workdir, '{0}-disable-cron.sh'.format(self.name))

        self._logger.debug('Rendering disable cron script from template')
        utils.render_template_to_file(
            template_path='crontab/disable.sh.template',
            file_path=disable_cron_script,
            name=self.name,
            workdir=self.workdir)
        self._runner.run('chmod +x {0}'.format(disable_cron_script))
        return disable_cron_script
Example #6
0
 def _create_config(self):
     self._logger.debug('Rendering configuration script from template')
     utils.render_template_to_file(
         template_path='pm/detach/detach.conf.template',
         file_path=self.config_path,
         user=self.user,
         name=self.name,
         broker_url=self.broker_url,
         manager_ip=self.manager_ip,
         manager_port=self.manager_port,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
     )
Example #7
0
    def create_disable_cron_script(self):

        disable_cron_script = os.path.join(
            self.workdir, '{0}-disable-cron.sh'.format(self.name))

        self._logger.debug('Rendering disable cron script from template')
        utils.render_template_to_file(
            template_path='crontab/disable.sh.template',
            file_path=disable_cron_script,
            name=self.name,
            workdir=self.workdir
        )
        self._runner.run('chmod +x {0}'.format(disable_cron_script))
        return disable_cron_script
Example #8
0
 def _create_config(self):
     self._logger.debug('Rendering configuration script from template')
     utils.render_template_to_file(
         template_path='pm/detach/detach.conf.template',
         file_path=self.config_path,
         user=self.user,
         name=self.name,
         broker_url=self.broker_url,
         manager_ip=self.manager_ip,
         manager_port=self.manager_port,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         workdir=self.workdir,
     )
Example #9
0
 def test_rendered_template_to_file(self):
     temp = utils.render_template_to_file(template_path=os.path.join(
         'pm', 'initd', 'initd.conf.template'),
                                          manager_ip='127.0.0.1')
     with open(temp) as f:
         rendered = f.read()
         self.assertTrue('export MANAGEMENT_IP=127.0.0.1' in rendered)
Example #10
0
 def _create_config(self):
     self._logger.debug('Rendering configuration script from template')
     rendered = utils.render_template_to_file(
         template_path='pm/initd/initd.conf.template',
         queue=self.queue,
         workdir=self.workdir,
         manager_ip=self.manager_ip,
         manager_port=self.manager_port,
         broker_url=self.broker_url,
         user=self.user,
         min_workers=self.min_workers,
         max_workers=self.max_workers,
         includes_path=self.includes_path,
         virtualenv_path=VIRTUALENV,
         extra_env_path=self.extra_env_path,
         name=self.name,
         storage_dir=utils.internal.get_storage_directory(self.user),
         log_level=self.log_level,
         log_file=self.get_logfile(),
         pid_file=self.pid_file,
         cron_respawn=str(self.cron_respawn).lower(),
         enable_cron_script=self.create_enable_cron_script(),
         disable_cron_script=self.create_disable_cron_script()
     )
     self._runner.run('sudo mkdir -p {0}'.format(
         os.path.dirname(self.config_path)))
     self._runner.run('sudo cp {0} {1}'.format(rendered, self.config_path))
     self._runner.run('sudo rm {0}'.format(rendered))
Example #11
0
def test_rendered_template_to_file():
    temp = utils.render_template_to_file(template_path=os.path.join(
        'pm', 'initd', 'initd.conf.template'),
                                         rest_host=['127.0.0.1'])
    with open(temp) as f:
        rendered = f.read()
        assert 'export REST_HOST="127.0.0.1"' in rendered
Example #12
0
 def test_rendered_template_to_file(self):
     temp = utils.render_template_to_file(template_path=os.path.join(
         'pm', 'initd', 'initd.conf.template'),
                                          rest_host='127.0.0.1')
     with open(temp) as f:
         rendered = f.read()
         self.assertTrue('export REST_HOST=127.0.0.1' in rendered)
Example #13
0
 def create_config(self):
     self._logger.debug(
         'Rendering configuration script "{0}" from template'.format(
             self.config_path))
     rendered = utils.render_template_to_file(
         template_path='pm/initd/initd.conf.template',
         queue=self.queue,
         workdir=self.workdir,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         broker_url=self.broker_url,
         user=self.user,
         min_workers=self.min_workers,
         max_workers=self.max_workers,
         virtualenv_path=VIRTUALENV,
         extra_env_path=self.extra_env_path,
         name=self.name,
         storage_dir=utils.internal.get_storage_directory(self.user),
         log_level=self.log_level,
         log_file=self.get_logfile(),
         pid_file=self.pid_file,
         cron_respawn=str(self.cron_respawn).lower(),
         enable_cron_script=self.create_enable_cron_script(),
         disable_cron_script=self.create_disable_cron_script(),
         cluster_settings_path=self.cluster_settings_path,
         executable_temp_path=self.executable_temp_path)
     self._runner.run('sudo mkdir -p {0}'.format(
         os.path.dirname(self.config_path)))
     self._runner.run('sudo cp {0} {1}'.format(rendered, self.config_path))
     self._runner.run('sudo rm {0}'.format(rendered))
Example #14
0
    def configure(self):

        env_string = self._create_env_string()

        # creating the installation script
        self._logger.debug('Rendering configuration script from template')
        utils.render_template_to_file(
            template_path='pm/nssm/nssm.conf.template',
            file_path=self.config_path,
            queue=self.queue,
            nssm_path=self.nssm_path,
            log_level=self.log_level,
            log_file=self.get_logfile(),
            workdir=self.workdir,
            user=self.user,
            manager_ip=self.manager_ip,
            manager_port=self.manager_port,
            broker_url=self.broker_url,
            min_workers=self.min_workers,
            max_workers=self.max_workers,
            includes=','.join(self.includes),
            virtualenv_path=VIRTUALENV,
            name=self.name,
            storage_dir=utils.internal.get_storage_directory(self.user),
            custom_environment=env_string,
            startup_policy=self.startup_policy,
            failure_reset_timeout=self.failure_reset_timeout,
            failure_restart_delay=self.failure_restart_delay
        )

        self._logger.debug('Rendered configuration script: {0}'.format(
            self.config_path))

        # run the configuration script
        self._logger.info('Running configuration script')
        self._runner.run(self.config_path)
        self._logger.debug('Successfully executed configuration script')

        # Add the celery config
        self._logger.info('Deploying SSL cert (if defined).')
        self._create_ssl_cert()
        self._logger.info('Deploying celery configuration.')
        self._create_celery_conf()

        # register plugins
        for plugin in included_plugins:
            self.register(plugin)
Example #15
0
    def create_config(self):
        # creating the installation script
        self._logger.info('Rendering configuration script "{0}" from template'
                          .format(self.config_path))
        utils.render_template_to_file(
            template_path='pm/nssm/nssm.conf.template',
            file_path=self.config_path,
            queue=self.queue,
            nssm_path=self.nssm_path,
            log_level=self.log_level.upper(),
            log_dir=self.log_dir,
            log_max_bytes=self.log_max_bytes,
            log_max_history=self.log_max_history,
            workdir=self.workdir,
            user=self.user,
            service_user=self.service_user,
            service_password=self.service_password,
            rest_host=self.rest_host,
            rest_port=self.rest_port,
            local_rest_cert_file=self.local_rest_cert_file,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            name=self.name,
            custom_environment=self._create_env_string(),
            executable_temp_path=self.executable_temp_path,
            startup_policy=self.startup_policy,
            failure_reset_timeout=self.failure_reset_timeout,
            failure_restart_delay=self.failure_restart_delay,
            storage_dir=utils.internal.get_storage_directory(self.user),
            cluster_settings_path=self.cluster_settings_path
        )

        self._logger.info('Rendered configuration script: {0}'.format(
            self.config_path))

        # run the configuration script
        self._logger.info('Running configuration script')
        try:
            self._runner.run(self.config_path)
        except Exception:
            # Log the exception here, then re-raise it. This is done in order
            # to ensure that the full exception message is shown.
            self._logger.exception("Failure encountered while running "
                                   "configuration script")
            raise
        self._logger.info('Successfully executed configuration script')
 def test_rendered_template_to_file(self):
     temp = utils.render_template_to_file(
         template_path=os.path.join('pm', 'initd', 'initd.conf.template'),
         rest_host='127.0.0.1'
     )
     with open(temp) as f:
         rendered = f.read()
         self.assertTrue('export REST_HOST="127.0.0.1"' in rendered)
 def test_rendered_template_to_file(self):
     temp = utils.render_template_to_file(
         template_path=os.path.join('pm', 'initd', 'initd.conf.template'),
         manager_ip='127.0.0.1'
     )
     with open(temp) as f:
         rendered = f.read()
         self.assertTrue('export MANAGEMENT_IP=127.0.0.1' in rendered)
Example #18
0
 def create_config(self):
     self._logger.debug(
         'Rendering configuration script "{0}" from template'.format(
             self.config_path))
     utils.render_template_to_file(
         template_path='pm/detach/detach.conf.template',
         file_path=self.config_path,
         user=self.user,
         name=self.name,
         broker_url=self.broker_url,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         workdir=self.workdir,
         cluster_settings_path=self.cluster_settings_path)
Example #19
0
    def create_config(self):
        env_string = self._create_env_string()

        # creating the installation script
        self._logger.debug('Rendering configuration script "{0}" from template'
                           .format(self.config_path))
        utils.render_template_to_file(
            template_path='pm/nssm/nssm.conf.template',
            file_path=self.config_path,
            queue=self.queue,
            nssm_path=self.nssm_path,
            log_level=self.log_level,
            log_file=self.get_logfile(),
            workdir=self.workdir,
            user=self.user,
            rest_host=self.rest_host,
            rest_port=self.rest_port,
            rest_protocol=self.rest_protocol,
            file_server_host=self.file_server_host,
            file_server_port=self.file_server_port,
            file_server_protocol=self.file_server_protocol,
            security_enabled=self.security_enabled,
            verify_rest_certificate=self.verify_rest_certificate,
            local_rest_cert_file=self.local_rest_cert_file,
            rest_cert_content=self.rest_cert_content,
            broker_url=self.broker_url,
            min_workers=self.min_workers,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            name=self.name,
            storage_dir=utils.internal.get_storage_directory(self.user),
            custom_environment=env_string,
            startup_policy=self.startup_policy,
            failure_reset_timeout=self.failure_reset_timeout,
            failure_restart_delay=self.failure_restart_delay
        )

        self._logger.debug('Rendered configuration script: {0}'.format(
            self.config_path))

        # run the configuration script
        self._logger.info('Running configuration script')
        self._runner.run(self.config_path)
        self._logger.debug('Successfully executed configuration script')
Example #20
0
 def create_script(self):
     self._logger.debug('Rendering init.d script from template')
     rendered = utils.render_template_to_file(
         template_path='pm/initd/initd.template',
         daemon_name=self.name,
         config_path=self.config_path)
     self._runner.run('sudo mkdir -p {0}'.format(
         os.path.dirname(self.script_path)))
     self._runner.run('sudo cp {0} {1}'.format(rendered, self.script_path))
     self._runner.run('sudo rm {0}'.format(rendered))
     self._runner.run('sudo chmod +x {0}'.format(self.script_path))
Example #21
0
 def create_config(self):
     self._logger.debug('Rendering configuration script "{0}" from template'
                        .format(self.config_path))
     utils.render_template_to_file(
         template_path='pm/detach/detach.conf.template',
         file_path=self.config_path,
         user=self.user,
         name=self.name,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         log_level=self.log_level.upper(),
         log_dir=self.log_dir,
         log_max_bytes=self.log_max_bytes,
         log_max_history=self.log_max_history,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         workdir=self.workdir,
         executable_temp_path=self.executable_temp_path,
     )
Example #22
0
 def create_config(self):
     self._logger.debug('Rendering configuration script "{0}" from template'.format(self.config_path))
     utils.render_template_to_file(
         template_path="pm/detach/detach.conf.template",
         file_path=self.config_path,
         user=self.user,
         name=self.name,
         broker_url=self.broker_url,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         rest_protocol=self.rest_protocol,
         file_server_host=self.file_server_host,
         file_server_port=self.file_server_port,
         file_server_protocol=self.file_server_protocol,
         security_enabled=self.security_enabled,
         verify_rest_certificate=self.verify_rest_certificate,
         local_rest_cert_file=self.local_rest_cert_file,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         workdir=self.workdir,
     )
Example #23
0
 def create_config(self):
     self._logger.debug('Rendering configuration script "{0}" from template'
                        .format(self.config_path))
     utils.render_template_to_file(
         template_path='pm/detach/detach.conf.template',
         file_path=self.config_path,
         user=self.user,
         name=self.name,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         log_level=self.log_level.upper(),
         log_dir=self.log_dir,
         log_max_bytes=self.log_max_bytes,
         log_max_history=self.log_max_history,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         workdir=self.workdir,
         executable_temp_path=self.executable_temp_path,
         cluster_settings_path=self.cluster_settings_path
     )
Example #24
0
 def _get_rendered_script(self):
     self._logger.debug('Rendering SystemD script from template')
     return utils.render_template_to_file(
         template_path='pm/systemd/systemd.template',
         virtualenv_path=VIRTUALENV,
         user=self.user,
         queue=self.queue,
         config_path=self.config_path,
         max_workers=self.max_workers,
         name=self.name,
         extra_env_path=self.extra_env_path,
     )
Example #25
0
 def _get_rendered_script(self):
     self._logger.debug('Rendering SystemD script from template')
     return utils.render_template_to_file(
         template_path='pm/systemd/systemd.template',
         virtualenv_path=VIRTUALENV,
         user=self.user,
         queue=self.queue,
         config_path=self.config_path,
         max_workers=self.max_workers,
         name=self.name,
         extra_env_path=self.extra_env_path,
     )
Example #26
0
 def create_script(self):
     self._logger.debug('Rendering init.d script from template')
     rendered = utils.render_template_to_file(
         template_path='pm/initd/initd.template',
         daemon_name=self.name,
         config_path=self.config_path
     )
     self._runner.run('sudo mkdir -p {0}'.format(
         os.path.dirname(self.script_path)))
     self._runner.run('sudo cp {0} {1}'.format(rendered, self.script_path))
     self._runner.run('sudo rm {0}'.format(rendered))
     self._runner.run('sudo chmod +x {0}'.format(self.script_path))
Example #27
0
 def _get_rendered_script(self):
     self._logger.debug('Rendering init.d script from template')
     return utils.render_template_to_file(
         template_path='pm/initd/initd.template',
         service_name=self.service_name,
         config_path=self.config_path,
         user=self.user,
         queue=self.queue,
         max_workers=self.max_workers,
         pidfile=self.pid_file,
         name=self.name,
         virtualenv_path=self.virtualenv,
         log_dir=self.log_dir)
Example #28
0
 def _get_rendered_script(self):
     self._logger.debug('Rendering init.d script from template')
     return utils.render_template_to_file(
         template_path='pm/initd/initd.template',
         service_name=self.service_name,
         config_path=self.config_path,
         user=self.user,
         queue=self.queue,
         max_workers=self.max_workers,
         pidfile=self.pid_file,
         name=self.name,
         virtualenv_path=self.virtualenv,
         log_dir=self.log_dir
     )
Example #29
0
 def _get_rendered_config(self):
     self._logger.debug(
         'Rendering configuration script "{0}" from template'.format(
             self.config_path))
     return utils.render_template_to_file(
         template_path='pm/systemd/systemd.conf.template',
         workdir=self.workdir,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         log_level=self.log_level.upper(),
         log_dir=self.log_dir,
         name=self.name,
         executable_temp_path=self.executable_temp_path,
     )
Example #30
0
 def _get_rendered_config(self):
     self._logger.debug('Rendering configuration script "{0}" from template'
                        .format(self.config_path))
     return utils.render_template_to_file(
         template_path='pm/systemd/systemd.conf.template',
         workdir=self.workdir,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         log_level=self.log_level.upper(),
         log_dir=self.log_dir,
         log_max_bytes=self.log_max_bytes,
         log_max_history=self.log_max_history,
         name=self.name,
         executable_temp_path=self.executable_temp_path,
         cluster_settings_path=self.cluster_settings_path
     )
Example #31
0
    def create_script(self):
        self._logger.debug('Rendering detached script from template')
        rendered = utils.render_template_to_file(
            template_path='pm/detach/detach.template',
            config_path=self.config_path,
            queue=self.queue,
            name=self.name,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            workdir=self.workdir,
            pid_file=self.pid_file
        )

        # no sudo needed, yey!
        self._runner.run('cp {0} {1}'.format(rendered, self.script_path))
        self._runner.run('rm {0}'.format(rendered))
        self._runner.run('chmod +x {0}'.format(self.script_path))
Example #32
0
    def create_script(self):
        self._logger.debug('Rendering detached script from template')
        rendered = utils.render_template_to_file(
            template_path='pm/detach/detach.template',
            config_path=self.config_path,
            queue=self.queue,
            name=self.name,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            workdir=self.workdir,
            pid_file=self.pid_file
        )

        # no sudo needed, yey!
        self._runner.run('cp {0} {1}'.format(rendered, self.script_path))
        self._runner.run('rm {0}'.format(rendered))
        self._runner.run('chmod +x {0}'.format(self.script_path))
Example #33
0
    def _create_script(self):
        self._logger.debug('Rendering detached script from template')
        rendered = utils.render_template_to_file(
            template_path='pm/detach/detach.template',
            config_path=self.config_path,
            queue=self.queue,
            name=self.name,
            log_level=self.log_level,
            log_file=self.get_logfile(),
            pid_file=self.pid_file,
            broker_url=self.broker_url,
            min_workers=self.min_workers,
            max_workers=self.max_workers,
            includes_path=self.includes_path,
            virtualenv_path=VIRTUALENV)

        # no sudo needed, yey!
        self._runner.run('cp {0} {1}'.format(rendered, self.script_path))
        self._runner.run('rm {0}'.format(rendered))
        self._runner.run('chmod +x {0}'.format(self.script_path))
Example #34
0
 def _get_rendered_config(self):
     self._logger.debug(
         'Rendering configuration script "{0}" from template'.format(
             self.config_path))
     return utils.render_template_to_file(
         template_path='pm/initd/initd.conf.template',
         queue=self.queue,
         workdir=self.workdir,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         log_level=self.log_level.upper(),
         log_dir=self.log_dir,
         cron_respawn=str(self.cron_respawn).lower(),
         enable_cron_script=self.create_enable_cron_script(),
         disable_cron_script=self.create_disable_cron_script(),
         executable_temp_path=self.executable_temp_path,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         name=self.name,
     )
Example #35
0
    def _create_script(self):
        self._logger.debug('Rendering detached script from template')
        rendered = utils.render_template_to_file(
            template_path='pm/detach/detach.template',
            config_path=self.config_path,
            queue=self.queue,
            name=self.name,
            log_level=self.log_level,
            log_file=self.log_file,
            pid_file=self.pid_file,
            broker_url=self.broker_url,
            min_workers=self.min_workers,
            max_workers=self.max_workers,
            includes_path=self.includes_path,
            virtualenv_path=VIRTUALENV
        )

        # no sudo needed, yey!
        self._runner.run('cp {0} {1}'.format(rendered, self.script_path))
        self._runner.run('rm {0}'.format(rendered))
        self._runner.run('chmod +x {0}'.format(self.script_path))
Example #36
0
    def create_script(self):
        self._logger.debug("Rendering detached script from template")
        rendered = utils.render_template_to_file(
            template_path="pm/detach/detach.template",
            config_path=self.config_path,
            queue=self.queue,
            name=self.name,
            log_level=self.log_level,
            log_file=self.get_logfile(),
            pid_file=self.pid_file,
            broker_url=self.broker_url,
            min_workers=self.min_workers,
            max_workers=self.max_workers,
            virtualenv_path=VIRTUALENV,
            workdir=self.workdir,
        )

        # no sudo needed, yey!
        self._runner.run("cp {0} {1}".format(rendered, self.script_path))
        self._runner.run("rm {0}".format(rendered))
        self._runner.run("chmod +x {0}".format(self.script_path))
Example #37
0
 def _get_rendered_config(self):
     self._logger.debug('Rendering configuration script "{0}" from template'
                        .format(self.config_path))
     return utils.render_template_to_file(
         template_path='pm/initd/initd.conf.template',
         queue=self.queue,
         workdir=self.workdir,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         local_rest_cert_file=self.local_rest_cert_file,
         log_level=self.log_level.upper(),
         log_dir=self.log_dir,
         log_max_bytes=self.log_max_bytes,
         log_max_history=self.log_max_history,
         cron_respawn=str(self.cron_respawn).lower(),
         enable_cron_script=self.create_enable_cron_script(),
         disable_cron_script=self.create_disable_cron_script(),
         executable_temp_path=self.executable_temp_path,
         extra_env_path=self.extra_env_path,
         storage_dir=utils.internal.get_storage_directory(self.user),
         name=self.name,
         cluster_settings_path=self.cluster_settings_path
     )
Example #38
0
 def create_config(self):
     self._logger.debug('Rendering configuration script "{0}" from template'
                        .format(self.config_path))
     rendered = utils.render_template_to_file(
         template_path='pm/initd/initd.conf.template',
         queue=self.queue,
         workdir=self.workdir,
         rest_host=self.rest_host,
         rest_port=self.rest_port,
         rest_protocol=self.rest_protocol,
         file_server_host=self.file_server_host,
         file_server_port=self.file_server_port,
         file_server_protocol=self.file_server_protocol,
         security_enabled=self.security_enabled,
         verify_rest_certificate=self.verify_rest_certificate,
         local_rest_cert_file=self.local_rest_cert_file,
         rest_cert_content=self.rest_cert_content,
         broker_url=self.broker_url,
         user=self.user,
         min_workers=self.min_workers,
         max_workers=self.max_workers,
         virtualenv_path=VIRTUALENV,
         extra_env_path=self.extra_env_path,
         name=self.name,
         storage_dir=utils.internal.get_storage_directory(self.user),
         log_level=self.log_level,
         log_file=self.get_logfile(),
         pid_file=self.pid_file,
         cron_respawn=str(self.cron_respawn).lower(),
         enable_cron_script=self.create_enable_cron_script(),
         disable_cron_script=self.create_disable_cron_script()
     )
     self._runner.run('sudo mkdir -p {0}'.format(
         os.path.dirname(self.config_path)))
     self._runner.run('sudo cp {0} {1}'.format(rendered, self.config_path))
     self._runner.run('sudo rm {0}'.format(rendered))