Bugfix script per build dell'applicazione per funzionare da qualsiasi
path Script di configurazione per i path incluso nel bin path dell'applicazione Correzioni allo script di build (settaggio permessi) Bugfix sistema di logging Bugfix system controller Inclusione base per sistema di crontab e task Inserito sistema di gestione variabili globali
This commit is contained in:
@@ -37,3 +37,6 @@ APPLICATION_BACKUPS_PATH="$APPLICATION_STORAGE/backups"
|
||||
APPLICATION_TMP_PATH="$APPLICATION_STORAGE/tmp"
|
||||
APPLICATION_CONFIG_PATH="$APPLICATION_PRIVATE/common"
|
||||
APPLICATION_BINARY_PATH="$APPLICATION_PRIVATE/bin"
|
||||
APPLICATION_CRON_PATH="$APPLICATION_PRIVATE/crontab"
|
||||
APPLICATION_TASK_PATH="$APPLICATION_PRIVATE/task"
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
# Permette cinque operazioni su database: Drop and rebuild all, Drop and rebuild all content, Drop and rebuild config, Add missing tables e Skip
|
||||
###########
|
||||
|
||||
my_dir="$(dirname "$0")"
|
||||
DIR_RETURN=`pwd`
|
||||
cd "$DIR_RETURN/$my_dir"
|
||||
|
||||
source "buildLibs"
|
||||
|
||||
OPTION_HELP=false # -h
|
||||
@@ -142,4 +146,7 @@ elif [ "$DATABASE_SKIP" = false ]; then
|
||||
database_add_missing
|
||||
fi
|
||||
|
||||
cp "$USE_CONFIG_FILE" "$APPLICATION_BINARY_PATH"
|
||||
|
||||
cd "$DIR_RETURN"
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ function deploy(){
|
||||
|
||||
|
||||
chmod -R a+x "$APPLICATION_BINARY_PATH"
|
||||
chmod -R a+x "$APPLICATION_CRON_PATH"
|
||||
chmod -R a+x "$APPLICATION_TASK_PATH"
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -116,6 +116,7 @@ function deploy(){
|
||||
|
||||
|
||||
chmod -R a+x "$APPLICATION_BINARY_PATH"
|
||||
chmod -R a+x "$APPLICATION_CRON_PATH"
|
||||
}
|
||||
|
||||
|
||||
@@ -148,8 +149,8 @@ function deploy_test_env(){
|
||||
function deploy_local_env(){
|
||||
create_project_fs
|
||||
deploy
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.local.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.local.php"
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.prod.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.prod.php"
|
||||
fi
|
||||
if [[ -f "$APPLICATION_CONFIG_PATH/config.test.php" ]];then
|
||||
rm "$APPLICATION_CONFIG_PATH/config.test.php"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# m h dom mon dow user command
|
||||
*/1 * * * * root /home/asdynamics/private/fdn2/bin/cronexec minute >> /dev/null 2>&1
|
||||
*/5 * * * * root /home/asdynamics/private/fdn2/bin/cronexec 5minutes >> /dev/null 2>&1
|
||||
59 * * * * root /home/asdynamics/private/fdn2/bin/cronexec hourly >> /dev/null 2>&1
|
||||
9 3 * * * root /home/asdynamics/private/fdn2/bin/cronexec daily >> /dev/null 2>&1
|
||||
19 4 * * 6 root /home/asdynamics/private/fdn2/bin/cronexec weekly >> /dev/null 2>&1
|
||||
29 5 1 * * root /home/asdynamics/private/fdn2/bin/cronexec monthly >> /dev/null 2>&1
|
||||
@@ -0,0 +1,3 @@
|
||||
modificare ".build.conf" nella root del progetto per impostare i path
|
||||
modificare l path nello script di crontab in /oth/OSConfig
|
||||
|
||||
+25
-15
@@ -1,25 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
my_dir="$(dirname "$0")"
|
||||
source "$my_dir/.build.config"
|
||||
|
||||
LOG_PREFIX="$APPLICATION_BUILDNAME-CRONEXEC"
|
||||
|
||||
if [ -z "$1" ];
|
||||
then
|
||||
echo "Missing specifier"
|
||||
exit 1
|
||||
logger "$LOG_PREFIX ERROR!!! Missing time specifier"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" == "5minutes" ] || [ "$1" == "minute" ] || [ "$1" == "daily" ] || [ "$1" == "hourly" ] || [ "$1" == "monthly" ] || [ "$1" == "weekly" ];
|
||||
then
|
||||
BASEDIR=`pwd`
|
||||
cd /eam/crontab/
|
||||
logger "CRONEXEC Executing $1 tasks"
|
||||
|
||||
for i in `ls | grep -P "\.$1\."`
|
||||
do
|
||||
logger "Executing $i"
|
||||
RESULT=`./$i`
|
||||
logger "$RESULT"
|
||||
done
|
||||
cd "$BASEDIR"
|
||||
logger "$LOG_PREFIX Executing '$1' tasks"
|
||||
|
||||
BASEDIR=`pwd`
|
||||
cd "$APPLICATION_CRON_PATH"
|
||||
|
||||
for i in `ls | grep -P "\.$1\."`
|
||||
do
|
||||
logger "$LOG_PREFIX Executing '$i' task"
|
||||
RESULT=`./$i`
|
||||
if [[ "$RESULT" = "" ]]; then
|
||||
logger "$LOG_PREFIX Execution of task '$i' completed"
|
||||
else
|
||||
logger "$LOG_PREFIX Task '$i' returned message '$RESULT'"
|
||||
fi
|
||||
done
|
||||
cd "$BASEDIR"
|
||||
else
|
||||
echo "Invalid specifier $1"
|
||||
exit 1
|
||||
logger "$LOG_PREFIX ERROR!!! Invalid time specifier"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -17,7 +17,7 @@ $database->connectionString = null;
|
||||
$currentSystem = new stdClass();
|
||||
$currentSystem->storageBaseDir = "/home/asdynamics/storage"; // Il path con storage ecc in cui mettere immagini, file temporanei ecc
|
||||
$currentSystem->privateBaseDir = "/home/asdynamics/private"; // Il path in cui inserire la cartella con lib, task, binari ecc
|
||||
$currentSystem->logBaseDir = "/var/log"; // Il path dei log....
|
||||
$currentSystem->logBaseDir = "/var/log/asdynamics"; // Il path dei log....
|
||||
$currentSystem->xSendFileDir = "/tmp/xsend";
|
||||
|
||||
$currentSystem->safeStorage = "/home/cbs/storage";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
// try {
|
||||
|
||||
// }
|
||||
// catch (UNHADBException $unex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
|
||||
// }
|
||||
// catch (Exception $ex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
|
||||
// }
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
// try {
|
||||
|
||||
|
||||
// }catch (UNHADBException $unex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
|
||||
// }
|
||||
// catch (Exception $ex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
|
||||
// }
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
// try {
|
||||
// SystemController::executeTask("RefreshApiCache.php");
|
||||
// }
|
||||
// catch (UNHADBException $unex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("GenerateReminderMail.php",$msg),true);
|
||||
|
||||
// }
|
||||
// catch (Exception $ex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("GenerateReminderMail.php",$msg),true);
|
||||
|
||||
// }
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 12/gen/2016
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
try {
|
||||
$task = "test";
|
||||
SystemController::executeTask("$task.php");
|
||||
}catch (CoreException $ex){
|
||||
$msg = "Error while executing task '$task' with message '".$ex->getMessage()."'";
|
||||
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
|
||||
}
|
||||
catch (Exception $ex){
|
||||
$msg = "Unexpected error while executing task '$task' with message '".$ex->getMessage()."'";
|
||||
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
// try {
|
||||
|
||||
// }catch (UNHADBException $unex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($unex->getMessage(),$unex->getData());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
|
||||
// }
|
||||
// catch (Exception $ex){
|
||||
// $msg = $application->core->loggingCatalogManager->getCatalog($ex->getMessage());
|
||||
// LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,"log.task.errorWhileExecutingTask",array("ProcessMailQueue.php",$msg),true);
|
||||
// }
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 12/gen/2016
|
||||
*/
|
||||
|
||||
class CataloguedException extends CoreException {
|
||||
protected $data;
|
||||
|
||||
public function __construct($msg,$exceptiondata = null) {
|
||||
parent::__construct($msg);
|
||||
if(!is_array($exceptiondata)) {
|
||||
$this->data = array($exceptiondata);
|
||||
}
|
||||
else {
|
||||
$this->data = $exceptiondata;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getData() {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 12/gen/2016
|
||||
*/
|
||||
|
||||
class GlobalVariables {
|
||||
private static $variables = array();
|
||||
|
||||
public static function set($name, $value){
|
||||
self::$variables[$name] = clone $value;
|
||||
}
|
||||
|
||||
public static function get($name){
|
||||
return self::$variables[$name];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -17,4 +17,5 @@ require_once(dirname(__FILE__)."/models/NotiziaModel.php");
|
||||
|
||||
$dao = new GenericDao($database->dbName,$database->connectionString);
|
||||
|
||||
GlobalVariables::set("dao", $dao);
|
||||
?>
|
||||
@@ -7,7 +7,11 @@ Creation Date: 14/nov/2013
|
||||
|
||||
require_once(dirname(__FILE__)."/CoreException.php");
|
||||
|
||||
// Constrained Objects
|
||||
require_once(dirname(__FILE__)."/CataloguedException.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/GlobalVariables.php");
|
||||
|
||||
GlobalVariables::set("config", $config);
|
||||
|
||||
// My instances
|
||||
require_once(dirname(__FILE__)."/lib.instances.php");
|
||||
@@ -25,7 +29,7 @@ require_once(dirname(__FILE__)."/system/lib.inclusion.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/dao/lib.inclusion.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/media/lib.inclusion.php");
|
||||
// require_once(dirname(__FILE__)."/media/lib.inclusion.php");
|
||||
|
||||
// asdasdasd
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class LoggingFacility {
|
||||
if($usecatalog) $finalMessage = $this->catalogManager->getCatalog($message,$data);
|
||||
else $finalMessage = $message;
|
||||
if($this->useDate) {
|
||||
$formattedDate = strftime($this->catalogManager->getCatalog("core.dateformat"),time());
|
||||
$formattedDate = strftime("%d/%m/%Y %H:%M:%S",time());
|
||||
$finalMessage = $this->myname . " " . $this->getIndicationForLevel($level)
|
||||
. " - " . $formattedDate . " > " . $finalMessage;
|
||||
}
|
||||
|
||||
@@ -7,18 +7,19 @@ Creation Date: 04/feb/2013
|
||||
|
||||
class LoggingFacilityManager {
|
||||
|
||||
private static $myloggers;
|
||||
private static $myloggers = array();
|
||||
|
||||
public static function addLogger($loggerName,&$loggerObject) {
|
||||
if(!isset(self::$myloggers)) self::$myloggers = array();
|
||||
public static function addLogger($loggerName, LoggingFacility &$loggerObject) {
|
||||
self::$myloggers[$loggerName] = $loggerObject;
|
||||
}
|
||||
|
||||
public static function getLogger($loggerName) {
|
||||
if(is_array(self::$myloggers) && array_key_exists($loggerName,self::$myloggers)) {
|
||||
if(array_key_exists($loggerName, self::$myloggers)) {
|
||||
return self::$myloggers[$loggerName];
|
||||
}
|
||||
else throw new CoreException("Impossible to find logger '$loggerName'");
|
||||
else {
|
||||
throw new CoreException("Impossible to find logger '$loggerName'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class SFSException extends CoreException {}
|
||||
class SFSException extends CataloguedException {}
|
||||
|
||||
class SFSManager {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class SystemException extends CoreException{}
|
||||
class SystemController {
|
||||
|
||||
private static function logMessage($level,$message,$data=null) {
|
||||
LoggingFacilityManager::getLogger("saam")->log($level,$message,$data,true);
|
||||
LoggingFacilityManager::getLogger("core")->log($level,$message,$data,true);
|
||||
}
|
||||
|
||||
public static function shellExec($cmdName,$cmdParams="",$sudo=false){
|
||||
@@ -33,12 +33,12 @@ class SystemController {
|
||||
}
|
||||
|
||||
public static function executeCustomCommand($cmdName,$cmdParams="",$sudo=false){
|
||||
$binpath = Context::getContextValue("sysconfig")->application->custom_bin_path;
|
||||
$binpath = GlobalVariables::get("config")->paths->binaries;
|
||||
return self::shellExec($binpath."/".$cmdName,$cmdParams,$sudo);
|
||||
}
|
||||
|
||||
public static function executeTask($cmdName,$cmdParams="",$sudo=false){
|
||||
$basePath = Context::getContextValue("sysconfig")->application->tasks_path;
|
||||
$basePath = GlobalVariables::get("config")->paths->task;
|
||||
return self::shellExec($basePath."/".$cmdName,$cmdParams,$sudo);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 12/gen/2016
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
try {
|
||||
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_DEBUG,"Execution of task 'test' begins");
|
||||
echo "OK";
|
||||
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_DEBUG,"Execution of task 'test' completed");
|
||||
}catch (CoreException $ex){
|
||||
$msg = "Error while executing task '$task' with message '".$ex->getMessage()."'";
|
||||
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
|
||||
}
|
||||
catch (Exception $ex){
|
||||
$msg = "Unexpected error while executing task '$task' with message '".$ex->getMessage()."'";
|
||||
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
|
||||
}
|
||||
|
||||
?>
|
||||
+2
-1
@@ -15,9 +15,10 @@ try {
|
||||
var_dump($model);
|
||||
echo "<br><br>";
|
||||
|
||||
// $model->immagini = array();
|
||||
$model->immagini = array();
|
||||
|
||||
$model->immagini[] = "1.jpg";
|
||||
$model->immagini[] = "2.jpg";
|
||||
$model->about->giorno = "boh";
|
||||
|
||||
var_dump($model);
|
||||
|
||||
Reference in New Issue
Block a user