-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: Fix tests. Improve error message on timeout. Fix tests. Fix database restore. Fix for filesystems. Return command results. Fix call to undefined function. Fix tests. Bugfixes for remote directory & databasecommand. Fix docblock. Add option to change to the physical remote directory, ignoring symlinks. Improve docblock. Added typehinting. Add gordalina/cachetool to require-dev. Fix tests. Fix test names. Fix typo in traitname. Fix code style issues. Fix code style issues. Added opcache & cleandir tasks & commands.
- Loading branch information
Showing
22 changed files
with
809 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace DigipolisGent\Robo\Task\Deploy; | ||
|
||
use Robo\Contract\CommandInterface; | ||
use Robo\Result; | ||
use Robo\Task\BaseTask; | ||
|
||
class ClearOpCache extends BaseTask implements CommandInterface | ||
{ | ||
use \Robo\Common\ExecCommand; | ||
|
||
const ENV_FCGI = 'fcgi'; | ||
const ENV_CLI = 'cli'; | ||
|
||
/** | ||
* The host type (cli or fcgi). | ||
* | ||
* @var string | ||
*/ | ||
protected $environment; | ||
|
||
/** | ||
* The fcgi host (if the environment is fcgi). | ||
* | ||
* @var string | ||
*/ | ||
protected $host; | ||
|
||
/** | ||
* Creates a new ClearOpCache task. | ||
* | ||
* @param string $environment | ||
* One of the ClearOpCache::ENV_* constants. | ||
* @param string $host | ||
* If the environment is FCGI, the host (path to socket or ip:port). | ||
*/ | ||
public function __construct($environment = self::ENV_FCGI, $host = null) | ||
{ | ||
$this->environment = $environment; | ||
$this->host = $host; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function run() | ||
{ | ||
if (!class_exists('\\CacheTool\\CacheTool')) { | ||
return Result::errorMissingPackage($this, '\\CacheTool\\CacheTool', 'gordalina/cachetool'); | ||
} | ||
|
||
$adapter = null; | ||
switch ($this->environment) { | ||
case static::ENV_CLI: | ||
$adapter = new \CacheTool\Adapter\Cli(); | ||
break; | ||
|
||
case static::ENV_FCGI: | ||
default: | ||
$adapter = new \CacheTool\Adapter\FastCGI($this->host); | ||
break; | ||
} | ||
$cachetool = \CacheTool\CacheTool::factory($adapter); | ||
$cachetool->opcache_reset(); | ||
return Result::success($this); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getCommand() | ||
{ | ||
$tool = $this->findExecutable('cachetool'); | ||
$cmd = $tool . ' opcache:reset --' . $this->environment; | ||
if ($this->environment === static::ENV_FCGI && $this->host) { | ||
$cmd .= '=' . $this->host; | ||
} | ||
return $cmd; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace DigipolisGent\Robo\Task\Deploy\Commands; | ||
|
||
use DigipolisGent\Robo\Task\Deploy\ClearOpCache as ClearOpCacheTask; | ||
|
||
trait ClearOpCache | ||
{ | ||
|
||
use \DigipolisGent\Robo\Task\Deploy\Traits\ClearOpCacheTrait; | ||
|
||
/** | ||
* Command digipolis:database-backup. | ||
* | ||
* @param string $environment | ||
* The environment. | ||
* @param array $opts | ||
* The command options. | ||
*/ | ||
public function digipolisClearOpCache( | ||
$environment = ClearOpCacheTask::ENV_FCGI, | ||
$opts = [ | ||
'host' => null, | ||
] | ||
) { | ||
$this->taskClearOpCache($environment, $opts['host'])->run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace DigipolisGent\Robo\Task\Deploy\Commands; | ||
|
||
use DigipolisGent\Robo\Task\Deploy\PartialCleanDirs as PartialCleanDirsTask; | ||
|
||
trait PartialCleanDirs | ||
{ | ||
|
||
use \DigipolisGent\Robo\Task\Deploy\Traits\PartialCleanDirsTrait; | ||
|
||
/** | ||
* Partially clean directories. | ||
* | ||
* @param array $dirs | ||
* Comma separated list of directories to clean. Each dir is optionally | ||
* followed by a colon and the number of items to preserve in that dir. | ||
* Defaults to 5 items. | ||
* @param array $opts | ||
* The command options. | ||
*/ | ||
public function digipolisCleanDir($dirs, $opts = ['sort' => PartialCleanDirsTask::SORT_NAME]) | ||
{ | ||
$dirsArg = array(); | ||
foreach (array_map('trim', explode(',', $dirs)) as $dir) { | ||
$dirParts = explode(':', $dir); | ||
if (count($dirParts) > 1) { | ||
$dirsArg[$dirParts[0]] = $dirParts[1]; | ||
continue; | ||
} | ||
$dirsArg[] = $dirParts[0]; | ||
} | ||
$this->taskPartialCleanDirs($dirsArg) | ||
->sortBy($opts['sort']) | ||
->run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.