mise en place d'un systeme de commande local

This commit is contained in:
afornerot 2021-03-26 09:26:52 +01:00
parent ae4debf6b9
commit dbade2fce4
3 changed files with 55 additions and 0 deletions

View File

@ -2,6 +2,7 @@
/app/config/parameters.yml /app/config/parameters.yml
/app/config/template.yml /app/config/template.yml
/src/Cadoles/CoreBundle/Command/data/core-init-01.sql /src/Cadoles/CoreBundle/Command/data/core-init-01.sql
/src/Cadoles/CoreBundle/Command/LocalCommand.php
/build/ /build/
/phpunit.xml /phpunit.xml
/var/* /var/*

View File

@ -0,0 +1,46 @@
<?php
namespace Cadoles\CoreBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Filesystem\Filesystem;
class LocalCommand extends Command
{
private $container;
private $em;
private $output;
private $filesystem;
private $rootlog;
protected function configure()
{
$this
->setName('Core:Local')
->setDescription('Lauch Local Script')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->container = $this->getApplication()->getKernel()->getContainer();
$this->em = $this->container->get('doctrine')->getEntityManager();
$this->output = $output;
$this->filesystem = new Filesystem();
$this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
return 1;
}
private function writelnred($string) {
$this->output->writeln('<fg=red>'.$string.'</>');
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
}
private function writeln($string) {
$this->output->writeln($string);
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
}
}

View File

@ -49,6 +49,11 @@ rm -f /var/www/html/ninegate/var/logs/dev.log
# Copie des polices du projet dans le rep web # Copie des polices du projet dans le rep web
cp -rf src/Cadoles/CoreBundle/Resources/public/fonts web/ cp -rf src/Cadoles/CoreBundle/Resources/public/fonts web/
# Copie de la commande local de base si elle la commande n'existe pas
if [ ! -f src/Cadoles/CoreBundle/Command/LocalCommand.php ]; then
cp -rf scripts/LocalCommand.php src/Cadoles/CoreBundle/Command/LocalCommand.php
fi
# Nettoyage du cache # Nettoyage du cache
echo echo
echo CACHE = Refresh echo CACHE = Refresh
@ -66,6 +71,9 @@ php bin/console Portal:InitData --env=prod
# Passage des scripts # Passage des scripts
php bin/console Core:Script --env=prod php bin/console Core:Script --env=prod
# Passage des scripts locaux
php bin/console Core:Local --env=prod
# Generation des assets # Generation des assets
echo ASSET = Dump echo ASSET = Dump
bin/console assetic:dump --env=prod --quiet bin/console assetic:dump --env=prod --quiet