Manage the state of services. This command checks for the presence of all the
    init systems pyinfra can handle and executes the relevant operation. See init
    system sepcific operation for arguments.
349754
def service(
    state, host,
    *args, **kwargs
):
    '''
    
    '''

    if host.fact.which('systemctl'):
        yield systemd(state, host, *args, **kwargs)
        return

    if host.fact.which('initctl'):
        yield upstart(state, host, *args, **kwargs)
        return

    if host.fact.directory('/etc/init.d'):
        yield d(state, host, *args, **kwargs)
        return

    if host.fact.directory('/etc/rc.d'):
        yield rc(state, host, *args, **kwargs)
        return

    raise OperationError((
        'No init system found '
        '(no systemctl, initctl, /etc/init.d or /etc/rc.d found)'
    ))
65730
def _service_is_sysv(name):
    '''
    
    '''
    script = '/etc/init.d/{0}'.format(name)
    return not _service_is_upstart(name) and os.access(script, os.X_OK)
73121
def service_network_restart():
    
    log = logging.getLogger(mod_logger + '.service_network_restart')
    command = ['service', 'network', 'restart']
    time.sleep(5)
    try:
        result = run_command(command)
        time.sleep(5)
        code = result['code']
    except CommandError:
        raise
    log.info('Network restart produced output:\n{o}'.format(o=result['output']))

    if code != 0:
        msg = 'Network services did not restart cleanly, exited with code: {c}'.format(c=code)
        log.error(msg)
        raise CommandError(msg)
    else:
        log.info('Successfully restarted networking!')
689382
def service_define(self, service, ty):
        

        assert service not in self._data
        assert service not in self._algebs + self._states

        self._service.append(service)
        self._service_ty.append(ty)
349662
def handle(self):
        
        self.output = PyStratumStyle(self.input, self.output)

        command = self.get_application().find('constants')
        ret = command.execute(self.input, self.output)
        if ret:
            return ret

        command = self.get_application().find('loader')
        ret = command.execute(self.input, self.output)
        if ret:
            return ret

        command = self.get_application().find('wrapper')
        ret = command.execute(self.input, self.output)

        self.output.writeln('')

        return ret
125304
def do_start_service(self, service):
        
        if not self.has_cluster():
            return None

        if self.service_action(service=service, action="start"):
            print("%s is being started" % (service))
        else:
            print("Error starting service")
            return None
1093772
def execute(self, processProtocol, command, env={},
                path=None, uid=None, gid=None, usePTY=0, childFDs=None):
        
        raise NotImplementedError()
516290
def wait_init(self):
        
        init_done = self.init_done.wait(timeout=self.init_wait_timeout)
        if not init_done:
            if hasattr(self, "peek"):
                app = self.config.get("application")
                if app:
                    bef_init_cmds = app.get("cli_ready_trigger")
                    if bef_init_cmds in self.peek():  # pylint: disable=no-member
                        init_done = True
        return init_done
511880
public function init()
    {
        Yii::setAlias('@maintenance', $this->commandPath);
        if (!file_exists(Yii::getAlias('@maintenance'))) {
            FileHelper::createDirectory(Yii::getAlias('@maintenance'));
        }
        if (Yii::$app instanceof \yii\console\Application) {
            Yii::$app->controllerMap['maintenance'] = $this->consoleController;
        } else {
            if ($this->getIsEnabled()) {
                $this->filtering();
            }
        }
    }
1162910
def handle_initialize(self, data):
        '''
        
        '''
        self.tuner.update_search_space(data)
        send(CommandType.Initialized, '')
        return True
88412
def do_status(self, service):
        
        if service:
            self.do_show("services", single=service)
        else:
            self.do_show("services")
328211
public function initialize()
    {
        if (true === $this->hasBeenInitialized) {
            return;
        }

        $this->hasBeenInitialized = true;

        foreach ($this->service as $service) {
            list($serviceClassName, $serviceOptions) = $this->manageServiceData($service);

            $this->serviceInstances[$serviceClassName] = $this->getServiceInstance($serviceClassName, $serviceOptions);
        }
    }
814532
def _state_run(self):
        '''
        
        '''
        if self.opts['startup_states']:
            if self.opts.get('master_type', 'str') == 'disable' and \
                        self.opts.get('file_client', 'remote') == 'remote':
                log.warning(
                    'Cannot run startup_states when \'master_type\' is set '
                    'to \'disable\' and \'file_client\' is set to '
                    '\'remote\'. Skipping.'
                )
            else:
                data = {'jid': 'req', 'ret': self.opts.get('ext_job_cache', '')}
                if self.opts['startup_states'] == 'sls':
                    data['fun'] = 'state.sls'
                    data['arg'] = [self.opts['sls_list']]
                elif self.opts['startup_states'] == 'top':
                    data['fun'] = 'state.top'
                    data['arg'] = [self.opts['top_file']]
                else:
                    data['fun'] = 'state.highstate'
                    data['arg'] = []
                self._handle_decoded_payload(data)
174394
def manage(options)
      init_log if options[:verbose]
      AgentConfig.cfg_dir = options[:cfg_dir]
      options[:timeout] ||= DEFAULT_TIMEOUT
      request_stats(options)
    rescue Exception => e
      fail("#{e}\n#{e.backtrace.join("\n")}") unless e.is_a?(SystemExit)
    end
183051
def enable(name, **kwargs):
    '''
    
    '''
    if _service_is_upstart(name):
        return _upstart_enable(name)
    executable = _get_service_exec()
    cmd = '{0} -f {1} defaults'.format(executable, name)
    return not __salt__['cmd.retcode'](cmd, python_shell=False)
723779
def service_status(self, name):
        

        return self._loop.run_coroutine(self._client.service_status(name))
583172
public void initSystem() {
        createIzouPropertiesFile();
        setSystemProperties();
        reloadFile(null);

        try {
            if (System.getProperty(IZOU_CONFIGURED).equals("false")) {
                fatal("Izou not completely configured, please configure Izou and launch again.");
                System.exit(0);
            }
        } catch (NullPointerException e) {
            fatal("Izou not completely configured, please configure Izou by editing izou.properties in the " +
                    "properties folder and launch again.");
            System.exit(0);
        }
    }