Wait for APP_STARTUP_TIMEOUT (120s) for an application's start message (CWWKZ0001I)
@param String appName
@param String testName
@param LibertyServer server
497748
public static void waitForAppStart(String appName, String className, LibertyServer server) {
        LOG.info("Setup : wait for the app startup complete (CWWKZ0001I) message for " + appName);

        String appStarted = server.waitForStringInLog("CWWKZ0001I.* " + appName, APP_STARTUP_TIMEOUT);
        if (appStarted == null) {
            Assert.fail(className + ": application " + appName + " failed to start within " + APP_STARTUP_TIMEOUT +"ms");
        }
    }
766998
void setAppName(final String appName) {
        if (clusterId.applicationName != null && !clusterId.applicationName.equals(appName))
            throw new IllegalStateException("Restting the application name on a cluster is not allowed.");
        clusterId = new ClusterId(appName, clusterId.clusterName);
    }
1339992
public void start(final int timeout, boolean daemon) throws IOException {
        this.myServerSocket = this.getServerSocketFactory().create();
        this.myServerSocket.setReuseAddress(true);

        ServerRunnable serverRunnable = createServerRunnable(timeout);
        this.myThread = new Thread(serverRunnable);
        this.myThread.setDaemon(daemon);
        this.myThread.setName("NanoHttpd Main Listener");
        this.myThread.start();
        while (!serverRunnable.hasBinded && serverRunnable.bindException == null) {
            try {
                Thread.sleep(10L);
            } catch (Throwable e) {
                // on android this may not be allowed, that's why we
                // catch throwable the wait should be very short because we are
                // just waiting for the bind of the socket
            }
        }
        if (serverRunnable.bindException != null) {
            throw serverRunnable.bindException;
        }
    }
1320425
@Override
    public void applicationStarted(ApplicationInfo appInfo) throws StateChangeException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(this, tc, "application started : " + appInfo.getName());

        runFutureGeneratePluginTask();

    }
974232
def wait_for_state(vmid, state, timeout=300):
    '''
    
    '''
    start_time = time.time()
    node = get_vm_status(vmid=vmid)
    if not node:
        log.error('wait_for_state: No VM retrieved based on given criteria.')
        raise SaltCloudExecutionFailure

    while True:
        if node['status'] == state:
            log.debug('Host %s is now in "%s" state!', node['name'], state)
            return True
        time.sleep(1)
        if time.time() - start_time > timeout:
            log.debug('Timeout reached while waiting for %s to become %s',
                      node['name'], state)
            return False
        node = get_vm_status(vmid=vmid)
        log.debug('State for %s is: "%s" instead of "%s"',
                  node['name'], node['status'], state)
725584
@Override
  public void onTimer(String timerName) {
    if (timerName.equals(IDLE_SESSION_TIMER_NAME)) {
      checkIdleAppSession();
    }
    else if (timerName.equals(TIMER_NAME_TS)) {
      if (context != null) {
        try {
          context.sessionTimeoutElapses(ServerRfSessionImpl.this);
        }
        catch (InternalException e) {
          logger.debug("Failure on processing expired Ts", e);
        }
      }
      setState(IDLE);
    }
    else {
      logger.warn("Received an unknown timer '{}' for Session-ID '{}'", timerName, getSessionId());
    }
  }
555921
private static boolean waitForServerUp(String hostname, int port, long timeout) {
    long start = System.currentTimeMillis();
    while (true) {
      try {
        Socket sock = new Socket(hostname, port);
        BufferedReader reader = null;
        try {
          OutputStream outstream = sock.getOutputStream();
          outstream.write("stat".getBytes());
          outstream.flush();

          Reader isr = new InputStreamReader(sock.getInputStream());
          reader = new BufferedReader(isr);
          String line = reader.readLine();
          if (line != null && line.startsWith("Zookeeper version:")) {
            return true;
          }
        } finally {
          sock.close();
          if (reader != null) {
            reader.close();
          }
        }
      } catch (IOException e) {
        // ignore as this is expected
        logger.info("server " + hostname + ":" + port + " not up " + e);
      }

      if (System.currentTimeMillis() > start + timeout) {
        break;
      }
      try {
        Thread.sleep(250);
      } catch (InterruptedException e) {
        // ignore
      }
    }
    return false;
  }
1129927
function internalStart(test) {

  	// If semaphore is non-numeric, throw error
  	if (isNaN(test.semaphore)) {
  		test.semaphore = 0;

  		pushFailure("Invalid value on test.semaphore", sourceFromStacktrace(2));
  		return;
  	}

  	// Don't start until equal number of stop-calls
  	if (test.semaphore > 0) {
  		return;
  	}

  	// Throw an Error if start is called more often than stop
  	if (test.semaphore < 0) {
  		test.semaphore = 0;

  		pushFailure("Tried to restart test while already started (test's semaphore was 0 already)", sourceFromStacktrace(2));
  		return;
  	}

  	// Add a slight delay to allow more assertions etc.
  	if (defined.setTimeout) {
  		if (config.timeout) {
  			clearTimeout(config.timeout);
  		}
  		config.timeout = setTimeout(function () {
  			if (test.semaphore > 0) {
  				return;
  			}

  			if (config.timeout) {
  				clearTimeout(config.timeout);
  			}

  			begin();
  		}, 13);
  	} else {
  		begin();
  	}
  }
2938
@Synchronized
    @SneakyThrows(Exception.class)
    private void tryInit() {
        if (!zkInit) {
            // we are making remote calls under a lock but this is only done for initialization at 
            // the start of controller process.
            ZKUtils.createPathIfNotExists(zkClient, zkPath, HostContainerMap.EMPTY.toBytes());
            hostContainerMapNode.getListenable().addListener(this::updateMap);
            hostContainerMapNode.start(true);
            updateMap();
            zkInit = true;
        }
    }
1210681
@Override
    public void _waitForNonStaleResults(Duration waitTimeout) {
        theWaitForNonStaleResults = true;
        timeout = ObjectUtils.firstNonNull(waitTimeout, getDefaultTimeout());
    }
233049
public void setTimeout(Object timeout) throws PageException {
	if (timeout instanceof TimeSpan) this.timeout = (TimeSpan) timeout;
	// seconds
	else {
	    int i = Caster.toIntValue(timeout);
	    if (i < 0) throw new ApplicationException("invalid value [" + i + "] for attribute timeout, value must be a positive integer greater or equal than 0");

	    this.timeout = new TimeSpanImpl(0, 0, 0, i);
	}
    }
423774
boolean isStarted(String appName) {
        lock.readLock().lock();
        try {
            return appStates.get(appName) == ApplicationState.STARTED;
        } finally {
            lock.readLock().unlock();
        }
    }
983182
public AppiumServiceBuilder withStartUpTimeOut(long time, TimeUnit timeUnit) {
        checkNotNull(timeUnit);
        checkArgument(time > 0, "Time value should be greater than zero", time);
        this.startupTimeout = time;
        this.timeUnit = timeUnit;
        return this;
    }
1290489
private SofaRpcException clientTimeoutWhenSendResponse(String appName, String serviceName, String remoteAddress) {
        String errorMsg = LogCodes.getLog(
            LogCodes.ERROR_DISCARD_TIMEOUT_RESPONSE, serviceName, remoteAddress);
        if (LOGGER.isWarnEnabled(appName)) {
            LOGGER.warnWithApp(appName, errorMsg);
        }
        return new SofaRpcException(RpcErrorType.SERVER_UNDECLARED_ERROR, errorMsg);
    }
54395
def run_unified_application_check(dns_name, port=8000)
      url_base = "#{dns_name}:#{port}"
      behavior(:test_http_response, "html serving succeeded", "#{url_base}/index.html", port) 
      behavior(:test_http_response, "configuration=succeeded", "#{url_base}/appserver/", port) 
      behavior(:test_http_response, "I am in the db", "#{url_base}/dbread/", port) 
      behavior(:test_http_response, "hostname=", "#{url_base}/serverid/", port) 
    end
95537
function launchApp(appName, appState, start, debug) {

	if (Array.isArray(start)) {

		// obtain appState
		if (!appState) {
			appState = {
				app: appName,
				created: Date.now(),
				crashCount: 0,
				killMap: {}
			}
		} else for (var aPid in appState.killMap) appState.killMap[aPid]()

		// launch the app
		var args = start.slice() // clone the array
		var command = args.shift() // extract command
		var child = child_process.spawn(command, args, options)
			.on('exit', childExit)
		streamlabeller.logChild(child, appName, write)
		var pid = appState.pid = child.pid
		appState.killMap[pid] = killChild
		var didKill
		var pendingKill
		var killTimer

		// update ui
		appState.lastLaunch = Date.now()
		appState.state = debug ? 'debug' : 'run'
		sendToUi({app: appName, pid: appState.pid, state: appState.state, lastLaunch: appState.lastLaunch})

	} else sendToUi({error: 'Bad launch command', isConfig: true, message: {app: appName}})

	return appState

	function killChild() {
		delete appState.killMap[pid]

		var t
		if (!didKill) {
			didKill = true
			pendingKill = true

			// update ui
			if (appState.pid == pid) {
				appState.state = 'stopping'
				sendToUi({app: appName, state: appState.state})
			}

			// attempt graceful kill (ctrl-Break)
			t = Date.now()
			killTimer = setTimeout(sigResult, graceKillPeriod)
			process.kill(pid, 'SIGINT')
		}

		function sigResult() {
			killTimer = null
			if (pendingKill) { // the process did not die
				//console.log(processName, proc.app, 'Force kill at: ' + (Date.now() - t) / 1e3)
				// now the evil sigterm
				process.kill(pid)
			}
		}
	}

	function childExit(code) {
		delete appState.killMap[pid]
		child.removeListener('exit', childExit)
		pendingKill = false
		if (killTimer) {
			clearTimeout(killTimer)
			killTimer = null
		}
		if (!didKill) appState.crashCount++
		if (appState.pid == pid) {
			appState.pid = 0
			appState.exitCode = code
			appState.lastExit = Date.now()
			appState.state = didKill ? 'stop' : 'crash'
			if (!didKill) appState.lastCrash = appState.lastExit
			sendToUi({app: appName, exit: appState.exitCode, state: appState.state, lastExit: appState.lastExit})
		}
		child = null
	}

}
391808
def wait_for_vm(instance_group_name, index, timeout_seconds, options = {deployment_name: Deployments::DEFAULT_DEPLOYMENT_NAME})
      start_time = Time.now
      loop do
        vm = instances(options).detect { |vm| !vm.vm_cid.empty? && vm.instance_group_name == instance_group_name && vm.index == index && vm.last_known_state != 'unresponsive agent' && vm.last_known_state != nil }
        return vm if vm
        break if Time.now - start_time >= timeout_seconds
        sleep(1)
      end

      @logger.info("Did not find VM after waiting for #{timeout_seconds}")
      nil
    end