Commit b499230f authored by Jordan Breton's avatar Jordan Breton

Merge branch 'dev'

parents da12021a c01c5bec
#!/usr/bin/php -q
<?php
use wfw\cli\backup\Backup;
use wfw\cli\backup\BackupManager;
use wfw\cli\backup\conf\BackupManagerConf;
......@@ -16,7 +15,7 @@ use wfw\engine\lib\data\string\serializer\LightSerializer;
use wfw\engine\lib\data\string\serializer\PHPSerializer;
use wfw\engine\lib\PHP\types\PHPString;
require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."init.environment.php";
require_once dirname(__FILE__,2)."/init.environment.php";
$argvReader = new ArgvReader(new ArgvParser(new ArgvOptMap([
new ArgvOpt("-list","Liste tous les backups du manager",0,null,true),
......@@ -29,7 +28,10 @@ $argvReader = new ArgvReader(new ArgvParser(new ArgvOptMap([
])),$argv);
try{
$confs = new BackupManagerConf(ENGINE.'/config/conf.json', SITE.'/config/conf.json');
$confs = new BackupManagerConf(
dirname(__DIR__,2).'/engine/config/conf.json',
dirname(__DIR__,2).'/site/config/conf.json'
);
$saveFile = $confs->getManagerFolder().'/manager.backup';
$serializer = new LightSerializer(new GZCompressor(), new PHPSerializer());
......@@ -41,7 +43,7 @@ try{
else $manager = new BackupManager($confs->getMaxBackups());
$args=[];
if(count($argv) === 1 || count($argv) === 2 && $argvReader->exists("-make")){
$dirs = glob(ROOT."/*",GLOB_ONLYDIR);
$dirs = glob(dirname(__DIR__,2)."/*",GLOB_ONLYDIR);
foreach($dirs as &$v){ $v = basename($v); }
$args = array_merge(["dbs"],array_diff($dirs,["backups",".",".."]));
var_dump($args);
......@@ -63,7 +65,7 @@ try{
array_shift($args);
$path = array_shift($args);
if(!(new PHPString($path))->startBy('/'))
$path = CLI."/$path";
$path = dirname(__DIR__)."/$path";
if(!is_dir($path))
throw new InvalidArgumentException("$path is not a valide directory");
$backupFolder = $path;
......@@ -91,11 +93,11 @@ try{
);
}
}else{
if(is_dir(ROOT."/$v")){
$backups[] = new LocalFilesBackup(ROOT."/$v",$backupFolder);
if(is_dir(dirname(__DIR__,2)."/$v")){
$backups[] = new LocalFilesBackup(dirname(__DIR__,2)."/$v",$backupFolder);
}else{
throw new InvalidArgumentException(
"Unknown backup type '$v' : Only direct folders under ".ROOT
"Unknown backup type '$v' : Only direct folders under ".dirname(__DIR__,2)
." or special keyword 'dbs' are accepted !"
);
}
......
......@@ -29,7 +29,8 @@ final class BackupManagerConf {
* @param string $basepath Chemin de base pour la résolution de chemins relatifs
* @throws \InvalidArgumentException
*/
public function __construct(string $engineConf,?string $siteConf, string $basepath = CLI) {
public function __construct(string $engineConf,?string $siteConf, ?string $basepath = null) {
if(is_null($basepath)) $basepath = dirname(__DIR__,2);
$this->_basepath = $basepath;
$confIo = new JSONConfIOAdapter();
$conf = new FileBasedConf($engineConf,$confIo);
......
<?php
require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."engine".DIRECTORY_SEPARATOR."webroot".DIRECTORY_SEPARATOR."init.environment.php";
require_once dirname(__FILE__,2)."/engine/webroot/init.environment.php";
(new \wfw\engine\core\errors\handlers\DefaultErrorHandler(false))->handle();
\ No newline at end of file
......@@ -6,7 +6,7 @@ use wfw\engine\lib\cli\argv\ArgvOptMap;
use wfw\engine\lib\cli\argv\ArgvParser;
use wfw\engine\lib\cli\argv\ArgvReader;
require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR."init.environment.php";
require_once dirname(__FILE__,2)."/init.environment.php";
$argvReader = new ArgvReader(new ArgvParser(new ArgvOptMap([
new ArgvOpt('-install','Installe un package pour le projet courant',null,null,true),
......@@ -23,47 +23,67 @@ try{
);
};
$site = dirname(__DIR__,2)."/site";
$engine = dirname(__DIR__,2)."/engine";
$modules = dirname(__DIR__,2)."/modules";
if($argvReader->exists('-install')){
$args = $argvReader->get('-install');
foreach($args as $package){
$tmp = explode("/",$package);
$location = SITE.'/package';
$location = $site.'/package';
$l = 'site';
if(count($tmp)===2){
$location = ($tmp[0] === 'engine')
? ENGINE."/package/".($p=$tmp[1]) : "$location/".($p=$tmp[1]);
$l = $tmp[0];
}
else $location = "$location/".($p = $tmp[0]);
if(is_dir($location)){
$webroot = array_diff(scandir("$location/webroot"),['..','.']);
foreach($webroot as $dir){
if(!is_dir(SITE."/webroot/$dir")) mkdir(SITE."/webroot/$dir");
if(is_link(SITE."/webroot/$dir/$p")) unlink(SITE."/webroot/$dir/$p");
chdir(SITE."/webroot/$dir");
$exec("ln -s \"../../../$l/package/$p/webroot/$dir\" \"$p\"");
$m = false;
if(count($tmp) > 1){
$l = array_shift($tmp);
$p = implode("/",$tmp);
switch($l){
case 'engine' :
$location = "$engine/package/$p";
break;
case 'modules' :
$location = "$modules/$p";
$m = true;
break;
default :
$location = "$location/$p";
}
}else fwrite(STDOUT,"\e[33mWFW_installer UNKNOWN_PACKAGE\e[0m : $package\n");
fwrite(STDOUT,"$package installed.\n");
} else $location = "$location/".($p = $tmp[0]);
if(is_dir("$location")){
if(is_dir("$location/webroot")){
$webroot = array_diff(scandir("$location/webroot"),['..','.']);
foreach($webroot as $dir){
if(!is_dir("$site/webroot/$dir")) mkdir("$site/webroot/$dir");
if(is_link("$site/webroot/$dir/$p")) unlink("$site/webroot/$dir/$p");
chdir("$site/webroot/$dir");
if(!is_dir(dirname($p))) mkdir(dirname($p),0777,true);
$relativeAdapt = str_repeat("../",count(explode("/",$p))+2);
$relativeAdapt = substr($relativeAdapt,0,-1);
if(!$m) $exec("ln -s \"$relativeAdapt/$l/package/$p/webroot/$dir\" \"$p\"");
else $exec("ln -s \"$relativeAdapt/$l/$p/webroot/$dir\" \"$p\"");
}
fwrite(STDOUT,"$package installed.\n");
}else fwrite(STDOUT,"$package : nothing to do (no webroot folder found).\n");
}else fwrite(STDOUT,"\e[33mWFW_installer UNKNOWN_PACKAGE\e[0m : $package : $location doesn't exists\n");
}
}else if($argvReader->exists('-uninstall')){
$args = $argvReader->get('-uninstall');
foreach($args as $package){
$tmp = explode("/",$package);
$location = SITE.'/package';
$location = $site.'/package';
$l = 'site';
if(count($tmp)===2){
$location = ($tmp[0] === 'engine')
? ENGINE."/package/".($p=$tmp[1]) : "$location/".($p=$tmp[1]);
? $engine."/package/".($p=$tmp[1]) : "$location/".($p=$tmp[1]);
$l = $tmp[0];
}
else $location = "$location/".($p = $tmp[0]);
if(is_dir($location)){
if(is_dir("$location/webroot")){
$webroot = array_diff(scandir("$location/webroot"),['..','.']);
foreach($webroot as $dir){
unlink(SITE."/webroot/$dir/$p");
unlink("$site/webroot/$dir/$p");
}
}else fwrite(STDOUT,"\e[33mWFW_installer UNKNOWN_PACKAGE\e[0m : $package\n");
}else fwrite(STDOUT,"\e[33mWFW_installer UNKNOWN_PACKAGE\e[0m : $package : $location/webroot doesn't exists\n");
}
}else throw new InvalidArgumentException("Unknown command $argv[1]");
}catch(\InvalidArgumentException $e){
......
@LOGDIR/*.log @LOGDIR/*/*.log @LOGDIR/*/*/*.log @LOGDIR/*/*/*/*.log{
daily
size 100M
size 10M
rotate 15
compress
delaycompress
missingok
create 644 root root
create 744 www-data www-data
}
\ No newline at end of file
[Unit]
Description=WFW real time server (rts)
[Service]
Type=simple
User=www-data
KillSignal=SIGALRM
KillMode=process
ExecStart=/usr/bin/php -q @ROOT/daemons/rts/RTSLauncher.php
Restart=always
[Install]
WantedBy=multi-user.target
\ No newline at end of file
......@@ -3,7 +3,6 @@ Alias /wfw @ROOT/cli/webroot
AllowOverride none
</Directory>
<Directory @ROOT/cli/webroot>
Require host localhost
Require ip 127.0.0.1
AllowOverride none
</Directory>
\ No newline at end of file
......@@ -36,7 +36,7 @@ fi
echo ""
declare -a services=("sctl" "kvs" "msserver")
declare -a services=("sctl" "kvs" "rts" "msserver")
for i in "${services[@]}"; do
#Reset the file if exists
DAEMONCONF="$INSTALLPATH/config/$i.systemctl"
......@@ -65,16 +65,6 @@ done
ln -s "$INSTALLPATH/../wfw/WFWGlobalLauncher.php" "/usr/bin/wfw"
echo "Created symlink $INSTALLPATH/../wfw/WFWGlobalLauncher.php -> /usr/bin/wfw"
echo ""
echo "Creating $A2CONF...";
cat "$INSTALLPATH/config/wfw-global.conf.template" | sed -e "s+@ROOT+$ROOTPATH+g" >> "$A2CONF"
echo "Moving $A2CONF to $A2CONF_PATH..."
mv "$A2CONF" "$A2CONF_PATH"
echo "Enabling wfw-global.conf..."
a2enconf wfw-global
echo "Reloading apache2..."
systemctl reload apache2
echo ""
echo "Creating $CONFPATH..."
mkdir -p "$CONFPATH"
......@@ -118,5 +108,15 @@ echo ""
ln -s "$A2_SITES_CONFS" "$A2PATH/wfw-sites"
echo "Created symlink $A2_SITES_CONFS -> $A2PATH/wfw-sites"
echo ""
echo "Creating $A2CONF...";
cat "$INSTALLPATH/config/wfw-global.conf.template" | sed -e "s+@ROOT+$ROOTPATH+g" >> "$A2CONF"
echo "Moving $A2CONF to $A2CONF_PATH..."
mv "$A2CONF" "$A2CONF_PATH"
echo "Enabling wfw-global.conf..."
a2enconf wfw-global
echo "Reloading apache2..."
systemctl reload apache2
echo ""
echo "Done."
\ No newline at end of file
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
"$DIR/uninstall.sh"
"$DIR/install.sh"
\ No newline at end of file
......@@ -12,7 +12,7 @@ LOGROTATE_PATH="/etc/logrotate.d/wfw"
A2_SITES_CONFS="/etc/apache2/wfw-sites"
A2CONF="/etc/apache2/conf-available/wfw-global.conf"
declare -a services=("msserver" "kvs" "sctl")
declare -a services=("msserver" "kvs" "rts" "sctl")
for i in "${services[@]}"
do
SERVICE_NAME="wfw-$i"
......
-- MySQL dump 10.13 Distrib 5.7.22, for Linux (x86_64)
--
-- Host: localhost Database: event_store
-- ------------------------------------------------------
-- Server version 5.7.22-0ubuntu0.16.04.1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `event_store`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `event_store_test` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `event_store_test`;
--
-- Table structure for table `aggregates`
--
DROP TABLE IF EXISTS `aggregates`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `aggregates` (
`id` binary(16) NOT NULL COMMENT 'UUID',
`type` varchar(255) DEFAULT NULL COMMENT 'Nom complet de l''agrégat',
`version` int(10) unsigned DEFAULT NULL COMMENT 'Version du dernier événement associé à cet aggrégat',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Aggrégat concerné par des événements';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `commands`
--
DROP TABLE IF EXISTS `commands`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `commands` (
`id` binary(16) NOT NULL COMMENT 'UUID',
`type` varchar(255) DEFAULT NULL COMMENT 'Nom complet de la commande',
`generation_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date de génération de la commande',
`processing_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date d''éxécution de la commande',
`writing_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date d''écriture de la commande en base de données',
`data` blob COMMENT 'Données transportées par la commande (langage agnostique)',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `events`
--
DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `events` (
`id` binary(16) NOT NULL COMMENT 'UUID',
`type` varchar(255) DEFAULT NULL COMMENT 'Nom de l''événement',
`data` blob COMMENT 'Données de l''événement (langage agnostique)',
`version` int(10) unsigned DEFAULT NULL COMMENT 'Version de l''événement (défini au niveau de l''aggrégat) ',
`generation_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date de génération de l''événement',
`writing_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date d''insertion en base de données',
`aggregates_id` binary(16) DEFAULT NULL COMMENT 'Aggrégat relatif à l''événement courant',
`commands_id` binary(16) DEFAULT NULL COMMENT 'Commande ayant entraîné la génération de l''événement',
PRIMARY KEY (`id`),
KEY `fk_events_aggregates_idx` (`aggregates_id`),
KEY `fk_events_commands1_idx` (`commands_id`),
CONSTRAINT `fk_events_aggregates` FOREIGN KEY (`aggregates_id`) REFERENCES `aggregates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_events_commands1` FOREIGN KEY (`commands_id`) REFERENCES `commands` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Evenements';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `snapshots`
--
DROP TABLE IF EXISTS `snapshots`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `snapshots` (
`id` binary(16) NOT NULL COMMENT 'UUID',
`aggregates_id` binary(16) DEFAULT NULL COMMENT 'UUID de l''aggrégat',
`data` blob COMMENT 'donnée sérialisée de l''état de l''aggrégat (langage agnostique)',
`version` int(10) unsigned DEFAULT NULL COMMENT 'Version du snapshot',
`generation_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date de génération du snapshot',
`writing_date` timestamp(6) NULL DEFAULT NULL COMMENT 'Date d''écriture du snapshot en base de données',
PRIMARY KEY (`id`),
KEY `fk_snapshots_aggregates1_idx` (`aggregates_id`),
CONSTRAINT `fk_snapshots_aggregates1` FOREIGN KEY (`aggregates_id`) REFERENCES `aggregates` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Représente un snapshot de de l''état d''un aggrégat à une version déterminée';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2018-06-07 17:24:24
{
//Contient la liste des environements de test disponibles
"environments" : {
"name" : "full\\class\\Name"
},
//Contient la liste des launchers de tests disponibles
"launchers" : {
"name" : "full\\class\\Name"
},
//Liste des sequences de tests disponibles.
//Chaque séquence est définie dans un launcher particulier.
//Chaque sequence est lancée dans un environnement séparé des autres séquences (nouveau processus)
//Si des environnements de test sont définis dans une séquence, ils seront utilisés tour à tour dans des séquences
//de tests séparées.
"sequences" : {
//Nom du launcher utilisé pour les sequences
"launcherName" : {
//Type de test (integration,unit,...)
"type" : {
//Nom de la séquence
"name" : {
//(optionnel) Description de la séquence
"description" : "Test sequence description",
//(optionnel) Liste des environnements à utiliser pour la séquence de tests (surtout pous les tests d'intégration)
"environments" : ["environmentName1","environmentName2"],
//Chemins vers les dossiers contenant les