@Override // notification from executed process public synchronized void onProcessStarted(LongLivedProcess process) { LOG.debug("Process has started"); processStarted = true; if (executionTimeout > 0) { setExecutor(ServiceThreadFactory.singleThreadExecutor(getName(), true)); execute(this); } }
@Override // notification from executed process public synchronized void onProcessStarted(LongLivedProcess process) { LOG.debug("Process has started"); processStarted = true; if (executionTimeout > 0) { setExecutor(ServiceThreadFactory.singleThreadExecutor(getName(), true)); execute(this); } }
/** * handle timeout response by escalating it to a failure */ @Override public void run() { try { synchronized (processTerminated) { if (!processTerminated.get()) { processTerminated.wait(executionTimeout); } } } catch (InterruptedException e) { //assume signalled; exit } //check the status; if the marker isn't true, bail if (!processTerminated.getAndSet(true)) { LOG.info("process timeout: reporting error code {}", timeoutCode); //timeout if (isInState(STATE.STARTED)) { //trigger a failure stopForkedProcess(); } reportFailure(timeoutCode, getName() + ": timeout after " + executionTimeout + " millis: exit code =" + timeoutCode); } }
/** * handle timeout response by escalating it to a failure */ @Override public void run() { try { synchronized (processTerminated) { if (!processTerminated.get()) { processTerminated.wait(executionTimeout); } } } catch (InterruptedException e) { //assume signalled; exit } //check the status; if the marker isn't true, bail if (!processTerminated.getAndSet(true)) { LOG.info("process timeout: reporting error code {}", timeoutCode); //timeout if (isInState(STATE.STARTED)) { //trigger a failure stopForkedProcess(); } reportFailure(timeoutCode, getName() + ": timeout after " + executionTimeout + " millis: exit code =" + timeoutCode); } }
@Override // notification from executed process public void onProcessExited(LongLivedProcess process, int uncorrected, int code) { try { synchronized (this) { completed(); //note whether or not the service had already stopped LOG.debug("Process has exited with exit code {}", code); if (code != 0) { reportFailure(code, getName() + " failed with code " + code); } } } finally { stop(); } }
@Override // notification from executed process public void onProcessExited(LongLivedProcess process, int uncorrected, int code) { try { synchronized (this) { completed(); //note whether or not the service had already stopped LOG.debug("Process has exited with exit code {}", code); if (code != 0) { reportFailure(code, getName() + " failed with code " + code); } } } finally { stop(); } }
/** * Build the process to execute when the service is started * @param commandList list of commands is inserted on the front * @param env environment variables above those generated by * @throws IOException IO problems */ public void build(Map<String, String> env, List<String> commandList) throws IOException { assert process == null; process = new LongLivedProcess(getName(), processLog, commandList); process.setLifecycleCallback(this); //set the env variable mapping process.putEnvMap(env); }
/** * Build the process to execute when the service is started * @param commandList list of commands is inserted on the front * @param env environment variables above those generated by * @throws IOException IO problems */ public void build(Map<String, String> env, List<String> commandList) throws IOException { assert process == null; process = new LongLivedProcess(getName(), processLog, commandList); process.setLifecycleCallback(this); //set the env variable mapping process.putEnvMap(env); }