check if restful server is running
172827
def check_rest(args):
    ''''''
    nni_config = Config(get_config_filename(args))
    rest_port = nni_config.get_config('restServerPort')
    running, _ = check_rest_server_quick(rest_port)
    if not running:
        print_normal('Restful server is running...')
    else:
        print_normal('Restful server is not running...')
1266676
def check_server_running(pid):
    
    if pid == os.getpid():
        # special case--we're in Docker or some other kind of container
        # (or we got really unlucky and got the same PID twice).
        # this PID does not correspond to another running server, either way.
        return False

    try:
        os.kill(pid, 0)
        return True
    except OSError as oe:
        if oe.errno == errno.ESRCH:
            return False
        else:
            raise
1243101
def _check_if_complete(self, url, json_response):
        
        if '__done' in json_response and isinstance(json_response, list):
            mr_parts = list(urlparse(url))
            mr_query = parse_qs(mr_parts[4])
            mr_query['mr'] = '"' + str(json_response[0]) + '"'
            mr_parts[4] = urlencode(mr_query, True)
            mr_link = urlunparse(mr_parts)
            mr_j, mr_r = self._ajax(mr_link)
            self.log.debug('MultipleRedirect link: %s', mr_link)
            return super(Installer, self)._check_if_complete(url, mr_j)

        return False
1322920
public static function checkNeeded(): void
    {
        set_time_limit(0);
        ignore_user_abort(true);
        ini_set('memory_limit', '1G');

        $services_collection = new ServiceEntityRepository;
        $services_collection
            ->setWhereRunning(0)
            ->setWhereAutoStart(1);

        /** @var ServiceEntity $service_entity */
        foreach ($services_collection->getAsArrayOfObjects() as $service_entity) {
            if (NOW - $service_entity->getLastTs() >= $service_entity->getPeriod()) {
                self::run($service_entity->getId());
            }
        }
    }
144992
def check_all_servers():
    """"""
    data = datatools.get_data()
    for server_id in data["discord"]["servers"]:
        is_in_client = False
        for client_server in client.servers:
            if server_id == client_server.id:
                is_in_client = True
                break

        if not is_in_client:
            remove_server_data(server_id)
722237
def turn_off
      _check_server!

      fail "Not active!" unless active?

      @detected.available.each do |obj|
        obj.turn_off if obj.respond_to?(:turn_off)
      end

      _env.notify_active = false
    end
11919
def verify_server_core(timeout=120, start_delay=90):
    ''' 
    '''
    timestamp = time.time()
    last_check = time.time() + start_delay - 10
    last_delay_notification = time.time() - 10
    server_down = True
    return_val = False
    timeout += 1
    # loop until the server is up or the timeout is reached
    while((time.time()-timestamp) < timeout) and server_down:
        # if delaying, the start of the check, print waiting to start
        if start_delay > 0 and time.time() - timestamp < start_delay \
                and (time.time()-last_delay_notification) > 5:
            print("Delaying server status check until %ss. Current time: %ss" \
                    % (start_delay, int(time.time() - timestamp)))
            last_delay_notification = time.time()
        # send a request check every 10s until the server is up
        while ((time.time()-last_check) > 10) and server_down:
            print("Checking status of servers at %ss" % \
                    int((time.time()-timestamp)))
            last_check = time.time()
            try:
                repo = requests.get(CFG.REPOSITORY_URL)
                repo_code = repo.status_code
                print ("\t", CFG.REPOSITORY_URL, " - ", repo_code)
            except:
                repo_code = 400
                print ("\t", CFG.REPOSITORY_URL, " - DOWN")
            try:
                triple = requests.get(CFG.DATA_TRIPLESTORE.url)
                triple_code = triple.status_code
                print ("\t", CFG.DATA_TRIPLESTORE.url, " - ", triple_code)
            except:
                triple_code = 400
                print ("\t", CFG.DATA_TRIPLESTORE.url, " - down")
            if repo_code == 200 and triple_code == 200:
                server_down = False
                return_val = True
                print("**** Servers up at %ss" % \
                    int((time.time()-timestamp)))
                break
    return return_val
526265
def start(self):
        """"""
        msg = ''
        if not self.running():
            if self._port == 0:
                self._port = _port_not_in_use()
            self._process = start_server_background(self._port)
        else:
            msg = 'Server already started\n'
        msg += 'Server running at {}'.format(self.url())
        print(msg)
1215858
def is_http_running_on(port):
  
  try:
    conn = httplib.HTTPConnection('127.0.0.1:' + str(port))
    conn.connect()
    conn.close()
    return True
  except Exception:
    return False
756399
function() {

    // Whitelist this in windows for now
    return bin.sh([DOCKER_EXECUTABLE, 'info'], {mode: 'collect'})

    // Return true if we get a zero response
    .then(function() {
      log.debug('Engine is up.');
      return Promise.resolve(true);
    })

    // Return false if we get a non-zero response
    .catch(function() {
      log.debug('Engine is down.');
      return Promise.resolve(false);
    });

  }
124835
def check_status(self):
        
        log = logging.getLogger("%s.%s" % (self.log_name,
                                           inspect.stack()[0][3]))
        log.setLevel(self.log_level)

        if self.url:
            return True
        try:
            result = requests.get(self.ext_url)
            self.url = self.ext_url
            return True
        except requests.exceptions.ConnectionError:
            pass
        try:
            result = requests.get(self.local_url)
            log.warning("Url '%s' not connecting. Using local_url '%s'" % \
                     (self.ext_url, self.local_url))
            self.url = self.local_url
            return True
        except requests.exceptions.ConnectionError:
            self.url = None
            log.warning("Unable to connect using urls: %s" % set([self.ext_url,
                                                               self.local_url]))
            return False
1299929
def is_active(self, timeout=2):
        
        try:
            result = Result(*self.perform_request('HEAD', '/', params={'request_timeout': timeout}))
        except ConnectionError:
            return False
        except TransportError:
            return False

        if result.response.status_code == 200:
            return True

        return False
80106
def check_server(self):
        
        msg = 'API server not found. Please check your API url configuration.'

        try:
            response = self.session.head(self.domain)
        except Exception as e:
            raise_from(errors.ServerError(msg), e)

        try:
            self._check_response(response)
        except errors.NotFound as e:
            raise raise_from(errors.ServerError(msg), e)
132768
def _check_connections(self):
        """"""

        for server in self._servers:
            if self._is_reachable(server):
                server['down_until'] = 0
            else:
                server['down_until'] = time.time() + 5
55140
def is_running(config, container, *args, **kwargs):
    '''
    
    '''
    try:
        infos = _get_container_infos(config, container)
        return (infos if infos.get('State', {}).get('Running') else None)
    except Exception:
        return None
545302
public static function check_server_status() {
        global $CFG;

        $url = $CFG->behat_wwwroot . '/admin/tool/behat/tests/behat/fixtures/environment.php';

        // Get web versions used by behat site.
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        $statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        if ($statuscode !== 200 || empty($result) || (!$result = json_decode($result, true))) {

            behat_error (BEHAT_EXITCODE_REQUIREMENT, $CFG->behat_wwwroot . ' is not available, ensure you specified ' .
                'correct url and that the server is set up and started.' . PHP_EOL . ' More info in ' .
                behat_command::DOCS_URL . PHP_EOL);
        }

        // Check if cli version is same as web version.
        $clienv = self::get_environment();
        if ($result != $clienv) {
            $output = 'Differences detected between cli and webserver...'.PHP_EOL;
            foreach ($result as $key => $version) {
                if ($clienv[$key] != $version) {
                    $output .= ' ' . $key . ': ' . PHP_EOL;
                    $output .= ' - web server: ' . $version . PHP_EOL;
                    $output .= ' - cli: ' . $clienv[$key] . PHP_EOL;
                }
            }
            echo $output;
            ob_flush();
        }
    }
24489
def ensure_started(self):
        
        # server is either starting or stopping (or error)
        if self.state in ['maintenance', 'error']:
            self._wait_for_state_change(['stopped', 'started'])

        if self.state == 'stopped':
            self.start()
            self._wait_for_state_change(['started'])

        if self.state == 'started':
            return True
        else:
            # something went wrong, fail explicitly
            raise Exception('unknown server state: ' + self.state)