mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
PHRAS-4011 : Moving cmd from console to setup - system:clear-cache system:clear-session (#4460)
* cmd clear cache in bin/setup * Change maintenance state wording
This commit is contained in:
@@ -14,6 +14,8 @@ namespace KonsoleKommander;
|
|||||||
use Alchemy\Phrasea\Command\Setup\ConfigurationEditor;
|
use Alchemy\Phrasea\Command\Setup\ConfigurationEditor;
|
||||||
use Alchemy\Phrasea\Command\Setup\FixAutoincrements;
|
use Alchemy\Phrasea\Command\Setup\FixAutoincrements;
|
||||||
use Alchemy\Phrasea\Command\Setup\FixLogCollId;
|
use Alchemy\Phrasea\Command\Setup\FixLogCollId;
|
||||||
|
use Alchemy\Phrasea\Command\Setup\SystemClearCacheCommand;
|
||||||
|
use Alchemy\Phrasea\Command\Setup\SystemClearSessionCacheCommand;
|
||||||
use Alchemy\Phrasea\Core\Version;
|
use Alchemy\Phrasea\Core\Version;
|
||||||
use Alchemy\Phrasea\Command\UpgradeDBDatas;
|
use Alchemy\Phrasea\Command\UpgradeDBDatas;
|
||||||
use Alchemy\Phrasea\Command\Setup\Install;
|
use Alchemy\Phrasea\Command\Setup\Install;
|
||||||
@@ -83,6 +85,9 @@ $app->command(new CrossDomainGenerator());
|
|||||||
$app->command(new FixAutoincrements('system:fix-autoincrements'));
|
$app->command(new FixAutoincrements('system:fix-autoincrements'));
|
||||||
$app->command(new FixLogCollId());
|
$app->command(new FixLogCollId());
|
||||||
|
|
||||||
|
$app->command(new SystemClearCacheCommand());
|
||||||
|
$app->command(new SystemClearSessionCacheCommand());
|
||||||
|
|
||||||
$app['phraseanet.setup_mode'] = true;
|
$app['phraseanet.setup_mode'] = true;
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
@@ -16,11 +16,11 @@ fi
|
|||||||
maintenance_manager()
|
maintenance_manager()
|
||||||
{
|
{
|
||||||
if [[ $1 = "off" || $1 = "0" ]];then
|
if [[ $1 = "off" || $1 = "0" ]];then
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet No Maintenance Mode Activated"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Maintenance disabled"
|
||||||
rm -rf /var/alchemy/Phraseanet/datas/nginx/maintenance.html
|
rm -rf /var/alchemy/Phraseanet/datas/nginx/maintenance.html
|
||||||
|
|
||||||
elif [[ $1 = "on" || $1 = "1" ]];then
|
elif [[ $1 = "on" || $1 = "1" ]];then
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Activating Maintenance Mode"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Maintenance enabled"
|
||||||
mkdir -p /var/alchemy/Phraseanet/datas/nginx
|
mkdir -p /var/alchemy/Phraseanet/datas/nginx
|
||||||
if [[ ! -n "$PHRASEANET_MAINTENANCE_MESSAGE" ]];then
|
if [[ ! -n "$PHRASEANET_MAINTENANCE_MESSAGE" ]];then
|
||||||
echo "No custom maintenance message"
|
echo "No custom maintenance message"
|
||||||
@@ -28,7 +28,7 @@ maintenance_manager()
|
|||||||
fi
|
fi
|
||||||
envsubst < "/usr/local/etc/maintenance.html" > /var/alchemy/Phraseanet/datas/nginx/maintenance.html
|
envsubst < "/usr/local/etc/maintenance.html" > /var/alchemy/Phraseanet/datas/nginx/maintenance.html
|
||||||
if [[ $2 != "noexit" ]];then
|
if [[ $2 != "noexit" ]];then
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Maintenance in persitent Mode"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Maintenance in persistent Mode"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Maintenance in temporary Mode"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet Maintenance in temporary Mode"
|
||||||
@@ -79,15 +79,15 @@ fi
|
|||||||
|
|
||||||
if [[ -f "$FILE" && $PHRASEANET_UPGRADE = 1 ]];then
|
if [[ -f "$FILE" && $PHRASEANET_UPGRADE = 1 ]];then
|
||||||
maintenance_manager 1 noexit
|
maintenance_manager 1 noexit
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - preparing config backup, check connection to db "
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - preparing Phraseanet configuration backup"
|
||||||
bin/console system:clear-cache
|
bin/setup system:clear-cache
|
||||||
bin/console system:clear-session
|
bin/setup system:clear-session
|
||||||
timestamp=$(date +'%Y-%m-%d_%H-%M-%S')
|
timestamp=$(date +'%Y-%m-%d_%H-%M-%S')
|
||||||
timestamp_dir="backup/pre-upgrade/$timestamp"
|
timestamp_dir="backup/pre-upgrade/$timestamp"
|
||||||
mkdir -p "$timestamp_dir"
|
mkdir -p "$timestamp_dir"
|
||||||
archive_name="$PHRASEANET_HOSTNAME-config.tgz"
|
archive_name="$PHRASEANET_HOSTNAME-config.tgz"
|
||||||
tar -zcf "$timestamp_dir/$archive_name" -C "config" .
|
tar -zcf "$timestamp_dir/$archive_name" -C "config" .
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - Pre-upgrade backup done for config $timestamp_dir/$archive_name"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - Pre-upgrade backup done for configuration $timestamp_dir/$archive_name"
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - Start Phraseanet upgrade datas"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - Start Phraseanet upgrade datas"
|
||||||
bin/setup system:upgrade -y
|
bin/setup system:upgrade -y
|
||||||
echo `date +"%Y-%m-%d %H:%M:%S"` " - End Phraseanet upgrade datas"
|
echo `date +"%Y-%m-%d %H:%M:%S"` " - End Phraseanet upgrade datas"
|
||||||
|
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2016 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Setup;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
|
|
||||||
|
class SystemClearCacheCommand extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct('system:clear-cache');
|
||||||
|
|
||||||
|
$this->setDescription('Empties cache directories and cache-server data');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$finder = new Finder();
|
||||||
|
|
||||||
|
$in = $this->container['cache.paths']->getArrayCopy();
|
||||||
|
$finder
|
||||||
|
->exclude('.git')
|
||||||
|
->exclude('.svn')
|
||||||
|
->in($in);
|
||||||
|
|
||||||
|
$this->container['filesystem']->remove($finder);
|
||||||
|
|
||||||
|
if ($this->container['phraseanet.configuration-tester']->isInstalled()) {
|
||||||
|
$this->getService('phraseanet.cache-service')->flushAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->write('Finished !', true);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Setup;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Cache\Factory;
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class SystemClearSessionCacheCommand extends Command
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct('system:clear-session-cache');
|
||||||
|
|
||||||
|
$this->setDescription('Empties session cache in redis, ends sessions for all users');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
/** @var Factory $cacheFactory */
|
||||||
|
$cacheFactory = $this->container['phraseanet.cache-factory'];
|
||||||
|
$cache = $cacheFactory->create('redis', ['host' => 'redis-session', 'port' => '6379']);
|
||||||
|
|
||||||
|
$flushOK = $cache->removeByPattern('PHPREDIS_SESSION*');
|
||||||
|
|
||||||
|
if ($flushOK) {
|
||||||
|
$output->writeln('session cache in redis successfully flushed!');
|
||||||
|
} else {
|
||||||
|
$output->writeln('flush failed!');
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@@ -21,7 +21,7 @@ class module_console_systemClearCache extends Command
|
|||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
|
|
||||||
$this->setDescription('Empties cache directories and cache-server data');
|
$this->setDescription('Empties cache directories and cache-server data <fg=yellow;>(Deprecated use bin/setup system:clear-cache instead)</>');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ class module_console_systemClearSessionCache extends Command
|
|||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
|
|
||||||
$this->setDescription('Empties session cache in redis');
|
$this->setDescription('Empties session cache in redis <fg=yellow;>(Deprecated use bin/setup system:clear-session-cache instead)</>');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user