本文整理汇总了PHP中Symfony\Component\Process\Process::stop方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::stop方法的具体用法?PHP Process::stop怎么用?PHP Process::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\Process
的用法示例。
在下文中一共展示了Process::stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stopServer
protected static function stopServer()
{
if (!static::$enabled) {
return;
}
self::$server->stop();
}
示例2: run
/**
* @param Process $process
* @param AdapterAbstract $testFrameworkAdapter
* @param callable $onProgressCallback
*
* @return bool
*/
public function run(Process $process, AdapterAbstract $testFrameworkAdapter, \Closure $onProgressCallback = null)
{
$hasFailure = false;
$process->run(function ($out, $data) use($process, $testFrameworkAdapter, $onProgressCallback, &$hasFailure) {
if ($out == Process::ERR) {
$hasFailure = true;
$process->stop();
return;
}
if ($hasFailure) {
return;
}
if (!$testFrameworkAdapter->ok($data)) {
$hasFailure = true;
$process->stop();
return;
}
$oksCount = $testFrameworkAdapter->hasOks($data);
if ($oksCount !== false && $onProgressCallback) {
$onProgressCallback($oksCount);
}
});
$process->stop();
return $hasFailure;
}
示例3: forceStop
/**
* @inheritdoc
*/
public function forceStop()
{
if (!$this->stopped) {
$this->process->stop();
}
$this->stopped = true;
}
示例4: stop
public function stop()
{
while ($this->isRunning()) {
$this->serverProcess->stop($this->timeout, SIGINT);
// it needs some time to stop
usleep(10);
}
}
示例5: stop
protected function stop()
{
if ($this->background && $this->process->isRunning()) {
$this->process->stop();
$this->printTaskInfo("Stopped <info>" . $this->getCommand() . "</info>");
}
}
示例6: testResponse
/**
* @dataProvider cbProvider
*/
public function testResponse($expectedStatusCode, $expectedResponseContent, $request, $testCase, $testHeaders)
{
$process = new Process('php -S [::1]:8999', __DIR__ . '/../../resources');
$process->start();
sleep(1);
$signature = sha1($request . ServerMock::PROJECT_SECRET_KEY);
$headers = null;
if ($testHeaders) {
$headers = $testHeaders;
} else {
$headers = array('Authorization' => 'Signature ' . $signature);
}
$request = $this->guzzleClient->post('/webhook_server.php?test_case=' . $testCase, $headers, $request);
try {
$response = $request->send();
} catch (BadResponseException $e) {
$process->stop();
$response = $e->getResponse();
}
static::assertSame($expectedResponseContent, $response->getBody(true));
static::assertSame($expectedStatusCode, $response->getStatusCode());
static::assertArrayHasKey('x-xsolla-sdk', $response->getHeaders());
static::assertSame(Version::getVersion(), (string) $response->getHeader('x-xsolla-sdk'));
static::assertArrayHasKey('content-type', $response->getHeaders());
if (204 === $response->getStatusCode()) {
static::assertStringStartsWith('text/plain', (string) $response->getHeader('content-type'));
} else {
static::assertStringStartsWith('application/json', (string) $response->getHeader('content-type'));
}
}
示例7: stop
protected function stop()
{
if ($this->background && $this->process->isRunning()) {
$this->process->stop();
$this->printTaskInfo("Stopped {command}", ['command' => $this->getCommand()]);
}
}
示例8: stop
public function stop()
{
if ($this->background && $this->process->isRunning()) {
$this->process->stop();
$this->printTaskInfo("stopped <info>{$this->command}</info>");
}
}
示例9: _terminate
/**
* Terminate current process
*
* @param int $timeout
* @param int $signal
*/
protected function _terminate($timeout = 10, $signal = 15)
{
foreach ($this->_getPidRecursive($this->getPid()) as $pid) {
posix_kill($pid, $signal);
}
parent::stop($timeout, $signal);
}
示例10: __destruct
/**
* Kills the connection
*/
public function __destruct()
{
if ($this->output->isVerbose()) {
$this->writeln("Closing SauceLabs tunnel.");
}
if (null !== $this->process) {
$this->process->stop();
}
}
示例11: testRequest404
public function testRequest404()
{
$process = new Process((new PhpExecutableFinder())->find() . ' -S 127.0.0.1:1337 -t ' . realpath(__DIR__));
$process->start();
sleep(1);
$request = new RequestProcess(new Request('GET', 'http://127.0.0.1:1337/InexistingRequest.php'));
$this->assertEquals($request->execute(), false);
$this->assertEquals($request->getError()['status'], 404);
$process->stop();
}
示例12: testFileDriverWithArrayArgument
public function testFileDriverWithArrayArgument()
{
$fileLock = new File('lock');
$fileLock->clearLocks();
$p = new Process('/usr/bin/php Tests/FileLockCommand.php test:file -s 1');
$p->start();
$decorator = new Decorator(new TestService(), 'test_service');
$lock = new Lock();
$lock->setDriver($fileLock)->setMethod('sleep')->setArgumentIndex(1);
$decorator->addLock($lock);
$decorator->sleep(1, array(1));
$p->stop();
return $this->assertTrue(true);
}
示例13: stop
/**
* Stops the server process
* @link https://github.com/symfony/Process
*/
public function stop()
{
if (null === $this->process) {
return;
}
if (!$this->isRunning()) {
return;
}
if (null !== $this->getConnection()) {
// Force a 'clean' exit
// See: http://stackoverflow.com/a/5266208/187954
$this->doEvalJS($this->getConnection(), 'process.exit(0);');
$this->process->stop();
$this->process = null;
}
}
示例14: fire
/**
* Fire and forget a command. It will be executed asynchronously, but you can get its output via the $callback.
*
* @param string $cmd Command to be fired.
* @param callable $callback [optional] Callback function that will be called periodically during command's execution
* and will take two arguments: 1st is a string buffer output and 2nd is bool error.
* You can return (bool) false from the callback to stop the running command.
*/
public function fire($cmd, $callback = null)
{
$process = new SymfonyProcess($cmd);
$process->start();
// if callback is defined then call it periodically
if (is_callable($callback)) {
while ($process->isRunning()) {
// call the callback
$continue = call_user_func_array($callback, array($process->getIncrementalOutput()));
// if callback returned false then stop the process
if ($continue === false) {
$process->stop(3, SIGINT);
}
}
}
}
示例15: testClient
public function testClient()
{
$process = new Process("gearman -w -f replace -- sed 's/__replace__/the best/g'");
$process->start();
try {
$this->assertEquals('php is the best', $this->client->doNormal('replace', 'php is __replace__'));
$this->assertEquals('php is the best', $this->client->doLow('replace', 'php is __replace__'));
$this->assertEquals('php is the best', $this->client->doHigh('replace', 'php is __replace__'));
$this->client->doBackground('replace', 'php is __replace__');
$this->client->doHighBackground('replace', 'php is __replace__');
$this->client->doLowBackground('replace', 'php is __replace__');
} catch (Exception\CouldNotConnectException $e) {
$this->markTestSkipped('Skipped, please start Gearman on port ' . Connection::DEFAULT_PORT . ' to be able to run this test');
}
$process->stop();
}