-
Notifications
You must be signed in to change notification settings - Fork 62
Start Varnish through Process component #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| namespace FOS\HttpCache\Tests; | ||
|
|
||
| use FOS\HttpCache\ProxyClient\Varnish; | ||
| use Symfony\Component\Process\Process; | ||
|
|
||
| /** | ||
| * A phpunit base class to write functional tests with varnish. | ||
|
|
@@ -143,7 +144,8 @@ protected function tearDown() | |
| protected function stopVarnish() | ||
| { | ||
| if (file_exists(self::PID)) { | ||
| exec('kill -9 ' . file_get_contents(self::PID)); | ||
| $process = new Process('kill -9 ' . file_get_contents(self::PID)); | ||
| $process->run(); // Ignore if command fails when Varnish wasn't running | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also doing this through process to suppress warning I also tried to make |
||
| unlink(self::PID); | ||
| $this->waitUntil('127.0.0.1', $this->getCachingProxyPort(), 2000); | ||
| } | ||
|
|
@@ -154,14 +156,20 @@ protected function stopVarnish() | |
| */ | ||
| protected function startVarnish() | ||
| { | ||
| exec($this->getBinary() . | ||
| $cmd = $this->getBinary() . | ||
| ' -a 127.0.0.1:' . $this->getCachingProxyPort() . | ||
| ' -T 127.0.0.1:' . $this->getVarnishMgmtPort() . | ||
| ' -f ' . $this->getConfigFile() . | ||
| ' -n ' . $this->getCacheDir() . | ||
| ' -p vcl_dir=' . $this->getConfigDir() . | ||
| ' -P ' . self::PID | ||
| ); | ||
| ' -P ' . self::PID; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest building this through the PRocessBuilder rather than using string concatenation, as this is missing shell escaping (if you have a space in the path to your config file, it will explode in your face for instance) |
||
|
|
||
| $process = new Process($cmd); | ||
| $process->run(); | ||
|
|
||
| if (!$process->isSuccessful()) { | ||
| throw new \RuntimeException($process->getErrorOutput()); | ||
| } | ||
|
|
||
| $this->waitFor('127.0.0.1', $this->getCachingProxyPort(), 2000); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require LTS version.