| 1 | <?php |
||
| 16 | class LiteSpeedProxy extends AbstractProxy |
||
| 17 | { |
||
| 18 | protected $binary = '/usr/local/lsws/bin/lswsctrl'; |
||
| 19 | |||
| 20 | protected $port = 8080; |
||
| 21 | |||
| 22 | protected $cacheDir = '/usr/local/lsws/cachedata'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * {@inheritdoc} |
||
| 26 | */ |
||
| 27 | public function start() |
||
| 28 | { |
||
| 29 | $process = $this->runCommand([ |
||
| 30 | $this->getBinary(), |
||
| 31 | 'status', |
||
| 32 | ], true); |
||
| 33 | |||
| 34 | // Already running |
||
| 35 | if (false !== strpos($process->getOutput(), 'litespeed is running with PID')) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | // Starting deamonized |
||
| 40 | $this->runCommand([ |
||
| 41 | $this->getBinary(), |
||
| 42 | 'start', |
||
| 43 | ], true); |
||
| 44 | |||
| 45 | $this->waitFor($this->getIp(), $this->getPort(), 2000); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | public function stop() |
||
| 52 | { |
||
| 53 | $this->runCommand([ |
||
| 54 | $this->getBinary(), |
||
| 55 | 'stop', |
||
| 56 | ], true); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * {@inheritdoc} |
||
| 61 | */ |
||
| 62 | public function clear() |
||
| 63 | { |
||
| 64 | // Runs as sudo to make sure it can be removed |
||
| 65 | $this->runCommand([ |
||
| 66 | 'rm', |
||
| 67 | '-rf', |
||
| 68 | $this->getCacheDir(), |
||
| 69 | ], true); |
||
| 70 | |||
| 71 | // Does not run as sudo to make sure it's created using the correct user |
||
| 72 | $this->runCommand([ |
||
| 73 | 'mkdir', |
||
| 74 | '-p', |
||
| 75 | $this->getCacheDir(), |
||
| 76 | ]); |
||
| 77 | |||
| 78 | $this->start(); |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param string $cacheDir |
||
| 83 | */ |
||
| 84 | public function setCacheDir($cacheDir) |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | public function getCacheDir() |
||
| 96 | } |
||
| 97 |