Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 30-initdrupal-does-not-move-the-gitignore-from-web_init-to-current-dir
  • 9-refactor-the-commands-as-lazy-loading-services
  • WOPS-104
  • WOPS-106
  • WOPS-108
  • WOPS-73
  • WOPS-75
  • WOPS-78
  • add-init-wp
  • check-display-port
  • config-path-priority
  • dns
  • dropcat-test-update
  • drush-10
  • fix_memory_limit
  • generate-correct-memory-value
  • innovation-day
  • issue-14
  • issue-17
  • issue-24
  • issue-28
  • master
  • memory_limit_etc
  • mixed_content_warning
  • move_backups_from_drush
  • move_command_keeptar
  • multi
  • newrelic
  • no_cr_before_updb
  • npm_install_dir_option
  • nuke-xdebug
  • rollbacks
  • simple
  • site_factory
  • sitefactory
  • swith_boolean
  • unified
  • uploadscp
  • varnish_url_param_fix
  • 0.1.0
  • 0.1.1
  • 0.1.2
  • 0.1.3
  • 0.1.4
  • 0.1.5
  • 1.0.0
  • 1.0.1
47 results

Target

Select target project
  • wunderpejer/dropcat
  • anders.olsson/dropcat
2 results
Select Git revision
Show changes
Commits on Source (15)
......@@ -3,7 +3,7 @@ services:
class: Symfony\Component\Console\Application
arguments:
- 'dropcat'
- '1.0.1'
- '1.0.3'
symfony.console_output:
class: Symfony\Component\Console\Output\ConsoleOutput
......@@ -285,3 +285,9 @@ services:
lazy: true
tags:
- {name: console.command, command: security:drupal}
dropcat.command.deploy:note:
class: Dropcat\Command\DeployNoteCommand
arguments: ['@DropcatContainer','@dropcat.configuration']
lazy: true
tags:
- {name: console.command, command: security:drupal}
......@@ -26,6 +26,12 @@ use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Console\Input\InputOption;
use Composer\XdebugHandler\XdebugHandler;
// Re-spawn if xdebug is loaded (unless DROPCAT_ALLOW_XDEBUG=1 is set).
$xdebug = new XdebugHandler('dropcat', '--ansi');
$xdebug->check();
unset($xdebug);
$container = new ContainerBuilder();
......
......@@ -31,7 +31,8 @@
"symfony/filesystem": "3.4",
"symfony/swiftmailer-bundle": "2.6.7",
"t4web/composer-lock-parser": "1.0.3",
"guzzlehttp/guzzle": "^6.3"
"guzzlehttp/guzzle": "^6.3",
"composer/xdebug-handler": "^1.3"
},
"bin": [
"app/dropcat"
......
This diff is collapsed.
<?php
namespace Dropcat\Command;
use Dropcat\Lib\DropcatCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
use Exception;
use phpseclib\Crypt\RSA;
use phpseclib\Net\SSH2;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use GuzzleHttp\Client;
/**
*
*/
class DeployNoteCommand extends DropcatCommand
{
/**
*
*/
protected function configure()
{
$HelpText = 'The <info>%command.name%</info> send payload of deploy to endpoint.';
$this->setName("deploy:note")
->setDescription("Send payload of deploy to endpoint")
->setDefinition(
[
new InputOption(
'server',
's',
InputOption::VALUE_OPTIONAL,
'Server',
$this->configuration->remoteEnvironmentServerName()
),
new InputOption(
'user',
'u',
InputOption::VALUE_OPTIONAL,
'User (ssh)',
$this->configuration->remoteEnvironmentSshUser()
),
new InputOption(
'ssh_port',
'p',
InputOption::VALUE_OPTIONAL,
'SSH port',
$this->configuration->remoteEnvironmentSshPort()
),
new InputOption(
'ssh_key_password',
'skp',
InputOption::VALUE_OPTIONAL,
'SSH key password',
$this->configuration->localEnvironmentSshKeyPassword()
),
new InputOption(
'identity_file',
'i',
InputOption::VALUE_OPTIONAL,
'Identify file',
$this->configuration->remoteEnvironmentIdentifyFile()
)
]
)
->setHelp($HelpText);
}
/**
*
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$server = $input->getOption('server');
$user = $input->getOption('user');
$ssh_port = $input->getOption('ssh_port');
$identity_file = $input->getOption('identity_file');
$identity_file_content = file_get_contents($identity_file);
$ssh_key_password = $input->getOption('ssh_key_password');
//define('NET_SSH2_LOGGING', 2);
$ssh = new SSH2($server, $ssh_port);
if ($output->isVerbose()) {
$output->writeln("<info>using server $server and port $ssh_port</info>");
}
$auth = new RSA();
if (isset($ssh_key_password)) {
$auth->setPassword($ssh_key_password);
if ($output->isVerbose()) {
$output->writeln("<info>using $ssh_key_password as password</info>");
}
}
if ($output->isVerbose()) {
$output->writeln("<info>loading key $identity_file</info>");
}
$auth->loadKey($identity_file_content);
if (!$ssh->login($user, $auth)) {
$output->writeln($ssh->getLog());
$output->writeln($ssh->getErrors());
$output->writeln("<info>Login Failed</info>");
exit(1);
}
$ssh->login($user, $auth);
if ($output->isVerbose()) {
$output->writeln("<info>logging in with user $user</info>");
}
$hostname = $ssh->exec('cat /etc/hostname');
echo $hostname;
try {
if (!isset($hostname)) {
throw new Exception('could not get hostname');
}
} catch (\Exception $e) {
echo 'error ' . $e->getMessage();
}
$deploy_url_endpoint = getenv('DEPLOY_URL_ENDPOINT');
echo $deploy_url_endpoint;
$output->writeln('<info>' . $this->mark .
' %command.name% finished</info>');
}
}
......@@ -211,11 +211,16 @@ To override config in dropcat.yml, using options:
}
$sites_folder = "$deploy_path/sites/";
$old_sites = "$temp_folder/old_sites";
$number_of_folders_original = $ssh->exec("ls -l $sites_folder | grep -c ^d");
$output->writeln("<info>Number of sites in sites folder including default before deploy: $number_of_folders_original</info>");
$ssh->exec("rsync -av --progress $sites_folder /tmp/$app_name-sites-$deploy_folder --exclude=default");
# $ssh->exec("rsync -av --progress $sites_folder /tmp/$app_name-sites-$deploy_folder --exclude=default");
$ssh->exec("mv $sites_folder $old_sites");
$status = $ssh->getExitStatus();
if ($status !== 0) {
echo "could not copy sites folder, error code $status\n";
echo "could not move sites folder, error code $status\n";
exit($status);
}
if (!($keeptar)) {
......@@ -249,27 +254,24 @@ To override config in dropcat.yml, using options:
if ($output->isVerbose()) {
$output->writeln("<info>$this->mark alias to deployed folder are: $web_root/$alias</info>");
}
$ssh->exec("cp -Rf /tmp/$app_name-sites-$deploy_folder/* $sites_folder");
$status = $ssh->getExitStatus();
$temp_sites = "$temp_folder/$build_id-sites";
$new_build_old_sites = "$deploy_path/sites";
$ssh->exec("mv $sites_folder $temp_sites && mv $old_sites $new_build_old_sites");
if ($status !== 0) {
echo "Could not move sites folder in place, error code $status\n";
exit($status);
}
$number_of_folders_new = $ssh->exec("ls -l $sites_folder | grep -c ^d");
$output->writeln("Number of sites in sites folder including default: $number_of_folders_new");
if ($number_of_folders_original !== $number_of_folders_new) {
$output->writeln("<error>Number of sites in sites folder does not match original. Aborted.</error>");
exit(1);
}
if ($output->isVerbose()) {
$output->writeln("<info>$this->mark sites folder moved in place</info>");
}
$ssh->exec("chmod 777 -R /tmp/$app_name-sites-$deploy_folder");
$ssh->exec("rm -rf /tmp/$app_name-sites-$deploy_folder");
// Commented out this check for now
$status = $ssh->getExitStatus();
if ($status !== 0) {
echo "Could not delete old sites folder, error code $status\n";
}
if ($output->isVerbose() && $status == 0) {
$output->writeln("<info>$this->mark old sites folder deleted</info>");
}
$ssh->disconnect();
$output->writeln("<info>$this->heart multi:move finished</info>");
......
......@@ -113,6 +113,13 @@ class ResetOpcacheCommand extends DropcatCommand
InputOption::VALUE_OPTIONAL,
'Basic auth pass',
null
),
new InputOption(
'curl_timeout',
'ct',
InputOption::VALUE_OPTIONAL,
'Curl time out ',
'10'
)
]
);
......@@ -131,6 +138,7 @@ class ResetOpcacheCommand extends DropcatCommand
$url = $input->getOption('url');
$auth_user = $input->getOption('auth-user');
$auth_pass = $input->getOption('auth-pass');
$curl_timeout = $input->getOption('curl_timeout');
$timeout = '999';
$verbose = false;
......@@ -177,8 +185,8 @@ class ResetOpcacheCommand extends DropcatCommand
}
// use curl to empty opcache
$request = new Process("curl -I $request_url");
$request->setTimeout(10);
$request = new Process("curl -Ik $request_url");
$request->setTimeout($curl_timeout);
$request->run();
// Executes after the command finishes.
if (!$request->isSuccessful()) {
......@@ -193,8 +201,8 @@ class ResetOpcacheCommand extends DropcatCommand
$request_url = str_replace('://', "://$auth_user:$auth_pass@", $request_url);
}
// use curl to warm opcache
$request = new Process("curl -I $request_url");
$request->setTimeout(10);
$request = new Process("curl -Ik $request_url");
$request->setTimeout($curl_timeout);
$request->run();
// Executes after the command finishes.
if (!$request->isSuccessful()) {
......
......@@ -141,7 +141,7 @@ class SecurityDrupalCommand extends DropcatCommand
if (in_array($status, $ok)) {
if ($status === 'deprecated') {
$output->writeln("<info>$this->mark drupal version $version is deprecated</info>");
$output->writeln("<error>THIS VERSION ($version) CAN'T BE DEPLOYED TO PRODUCTION!</error>");
$output->writeln("<error>THIS VERSION ($version) SHOULD NOT BE DEPLOYED TO PRODUCTION!</error>");
} else {
$output->writeln("<info>$this->heart drupal version $version is ok</info>");
}
......@@ -152,7 +152,7 @@ class SecurityDrupalCommand extends DropcatCommand
exit(1);
} else {
$output->writeln("<info>$this->error drupal version $version is not secure</info>");
$output->writeln("<error>ERROR!!!</error>");
$output->writeln("<error>ERROR!!! CAN NOT BE DEPLOYED TO PRODUCTION!</error>");
exit(1);
}
}
......
......@@ -23,7 +23,8 @@ class UpdateCommand extends DropcatCommand
*/
protected function configure()
{
$HelpText = 'The <info>update-database</info> command updates db if needed.
$HelpText = 'The <info>update</info> command updates db if needed, also imports
config and do config split if options supplied.
<comment>Samples:</comment>
To run with default options (using config from dropcat.yml in the currrent dir):
<info>dropcat update</info>';
......@@ -87,6 +88,12 @@ To run with default options (using config from dropcat.yml in the currrent dir):
InputOption::VALUE_NONE,
'Cache rebuild after update db'
),
new InputOption(
'no-cache-rebuild-before-updatedb',
null,
InputOption::VALUE_NONE,
'Cache rebuild before update db'
),
new InputOption(
'config-split-settings',
null,
......@@ -113,6 +120,7 @@ To run with default options (using config from dropcat.yml in the currrent dir):
$config_partial = $input->getOption('use-config-import-partial') ? true : false;
$multi = $input->getOption('multi') ? true : false;
$no_cr_after_updb = $input->getOption('no-cache-rebuild-after-updatedb') ? true : false;
$no_cr_before_updb = $input->getOption('no-cache-rebuild-before-updatedb') ? true : false;
$config_split_settings = $input->getOption('config-split-settings');
// If we have an option for config split settings, config split should be true.
......@@ -183,47 +191,54 @@ To run with default options (using config from dropcat.yml in the currrent dir):
$site = $this->configuration->localEnvironmentAppName();
}
if (isset($siteProperty['drush']['alias'])) {
$alias = $siteProperty['drush']['alias'];
// Backup
// create dir if it does not exist
/*
$backup_dir = $this->configuration->siteEnvironmentBackupPath() .
'/' . $this->configuration->localEnvironmentAppName() . '/' .
$alias;
$process = new Process("mkdir -p $backup_dir");
if ($version == '7') {
$process = new Process("drush @$alias drush vset maintenance_mode 1 && drush @$alias sql-query 'TRUNCATE TABLE sessions;'");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error could not create backup dir.</info>");
$output->writeln("<info>$this->error could not set $site in maintenance mode</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}
$server_time = date("Ymd_His");
$process = new Process("drush @$alias sql-dump -y > $backup_dir/$alias-$server_time.sql");
$output->writeln("<info>$this->mark $site is in maintenance mode</info>");
}
if ($version == '8') {
$process = new Process("drush @$alias sset system.maintenance_mode 1 && drush @$alias sql-query 'TRUNCATE TABLE sessions;'");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error could not update db for $site</info>");
$output->writeln("<info>$this->error could not set $site in maintenance mode</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}
$output->writeln("<info>$this->mark update db done for $alias</info>");
$output->writeln("<info>$this->mark $site is in maintenance mode</info>");
*/
// end backup.
$process = new Process("drush @$alias cr");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error could not rebuild cache for $site</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}
$output->writeln("<info>$this->mark rebuild cache done for $site</info>");
}
$alias = $siteProperty['drush']['alias'];
if ($no_db_update == false) {
if ($version == '8') {
if ($no_cr_before_updb == false) {
// First rebuild cahce.
$process = new Process("drush @$alias cr");
$process->setTimeout(9999);
......@@ -237,6 +252,7 @@ To run with default options (using config from dropcat.yml in the currrent dir):
echo $process->getOutput();
}
}
}
$process = new Process("drush @$alias updb -y $ent");
$process->setTimeout(9999);
$process->run();
......@@ -268,48 +284,7 @@ To run with default options (using config from dropcat.yml in the currrent dir):
$output->writeln("<info>$this->mark cleared cache for $site</info>");
}
if ($version == '8') {
$process = new Process("drush @$alias sset system.maintenance_mode 1 && drush @$alias sql-query 'TRUNCATE TABLE sessions;'");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error could not set $site in maintenance mode</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}
$output->writeln("<info>$this->mark $site is in maintenance mode</info>");
$process = new Process("drush @$alias cr");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error could not rebuild cache for $site</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}
$process = new Process("drush @$alias cr");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error could not rebuild cache for $site</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}
$output->writeln("<info>$this->mark rebuild cache done for $site</info>");
}
}
if ($config_split == true) {
......@@ -361,19 +336,6 @@ To run with default options (using config from dropcat.yml in the currrent dir):
$output->writeln("<info>$this->mark config split export done for $site</info>");
if ($no_config_import == false) {
if ($version == '8') {
// Remove partial for now.
/* $output->writeln("<info>$this->mark starting partial config import for $site</info>");
$process = new Process("drush @$alias cim -y --partial");
$process->setTimeout(9999);
$process->run();
// Executes after the command finishes.
if (!$process->isSuccessful()) {
$output->writeln("<info>$this->error config import failed for $site</info>");
throw new ProcessFailedException($process);
}
if ($output->isVerbose()) {
echo $process->getOutput();
}*/
$output->writeln("<info>$this->mark starting config import for $site</info>");
$process = new Process("drush @$alias cim -y $part");
$process->setTimeout(9999);
......
......@@ -63,11 +63,19 @@ class VarnishPurgeCommand extends DropcatCommand
$errstr,
10
);
if (!$varnish_sock) {
echo "connections failed $errno $errstr";
exit;
}
if ($url){
$target = $url;
}
else {
$target = $this->configuration->siteEnvironmentUrl();
}
$host = parse_url($target,PHP_URL_HOST);
$host = parse_url(
$this->configuration->siteEnvironmentUrl(),
PHP_URL_HOST
);
// Prepare the command to send
$cmd = "DOMAINPURGE / HTTP/1.0\r\n";
$cmd .= "Host: " . $host . "\r\n";
......
......@@ -806,4 +806,17 @@ class UnifiedConfiguration extends DropcatConfigurationBase implements DropcatCo
return null;
}
}
/**
* Get drush php memory
*/
public function remoteEnvironmentDrushMemoryLimit()
{
if (isset($this->configuration['remote']['environment']['drush']['limit'])) {
return '"-d memory_limit=' . $this->configuration['remote']['environment']['drush']['limit'] . '"';
} else {
return '-d memory_limit=1024M';
}
}
}