diff --git a/.build.config b/.build.config
index 624c11f..4a583b2 100644
--- a/.build.config
+++ b/.build.config
@@ -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"
+
diff --git a/build b/build
index 5dbd7fe..f3b7414 100755
--- a/build
+++ b/build
@@ -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"
diff --git a/buildLibs b/buildLibs
index eda0563..591624a 100644
--- a/buildLibs
+++ b/buildLibs
@@ -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"
}
diff --git a/buildLibs~ b/buildLibs~
index 138db39..8db03b8 100644
--- a/buildLibs~
+++ b/buildLibs~
@@ -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"
diff --git a/oth/OSConfig/crontab b/oth/OSConfig/crontab
new file mode 100644
index 0000000..27b7f66
--- /dev/null
+++ b/oth/OSConfig/crontab
@@ -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
diff --git a/oth/docs/install.memo b/oth/docs/install.memo
new file mode 100644
index 0000000..ff16029
--- /dev/null
+++ b/oth/docs/install.memo
@@ -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
+
\ No newline at end of file
diff --git a/private/bin/cronexec b/private/bin/cronexec
index b4eaafd..36fbf64 100644
--- a/private/bin/cronexec
+++ b/private/bin/cronexec
@@ -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
diff --git a/private/common/config.local.php b/private/common/config.local.php
index acce2eb..271a8de 100644
--- a/private/common/config.local.php
+++ b/private/common/config.local.php
@@ -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";
diff --git a/private/crontab/core.5minutes.php b/private/crontab/core.5minutes.php
new file mode 100644
index 0000000..8adf356
--- /dev/null
+++ b/private/crontab/core.5minutes.php
@@ -0,0 +1,18 @@
+#!/usr/bin/php
+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);
+// }
+
+
+?>
\ No newline at end of file
diff --git a/private/crontab/core.daily.php b/private/crontab/core.daily.php
new file mode 100644
index 0000000..dee4448
--- /dev/null
+++ b/private/crontab/core.daily.php
@@ -0,0 +1,17 @@
+#!/usr/bin/php
+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);
+// }
+
+?>
\ No newline at end of file
diff --git a/private/crontab/core.hourly.php b/private/crontab/core.hourly.php
new file mode 100644
index 0000000..e4eaccf
--- /dev/null
+++ b/private/crontab/core.hourly.php
@@ -0,0 +1,19 @@
+#!/usr/bin/php
+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);
+
+// }
+
+?>
\ No newline at end of file
diff --git a/private/crontab/core.minute.php b/private/crontab/core.minute.php
new file mode 100644
index 0000000..b2cdfc4
--- /dev/null
+++ b/private/crontab/core.minute.php
@@ -0,0 +1,22 @@
+#!/usr/bin/php
+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);
+}
+
+?>
\ No newline at end of file
diff --git a/private/crontab/core.monthly.php b/private/crontab/core.monthly.php
new file mode 100644
index 0000000..b874a34
--- /dev/null
+++ b/private/crontab/core.monthly.php
@@ -0,0 +1,5 @@
+#!/usr/bin/php
+
\ No newline at end of file
diff --git a/private/crontab/core.weekly.php b/private/crontab/core.weekly.php
new file mode 100644
index 0000000..9ffa646
--- /dev/null
+++ b/private/crontab/core.weekly.php
@@ -0,0 +1,16 @@
+#!/usr/bin/php
+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);
+// }
+
+?>
\ No newline at end of file
diff --git a/private/lib/CataloguedException.php b/private/lib/CataloguedException.php
new file mode 100644
index 0000000..7b59c12
--- /dev/null
+++ b/private/lib/CataloguedException.php
@@ -0,0 +1,27 @@
+data = array($exceptiondata);
+ }
+ else {
+ $this->data = $exceptiondata;
+ }
+
+ }
+
+ public function getData() {
+ return $this->data;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/private/lib/GlobalVariables.php b/private/lib/GlobalVariables.php
new file mode 100644
index 0000000..890f915
--- /dev/null
+++ b/private/lib/GlobalVariables.php
@@ -0,0 +1,20 @@
+
\ No newline at end of file
diff --git a/private/lib/dao/lib.inclusion.php b/private/lib/dao/lib.inclusion.php
index 9b7b76c..4d7a8f1 100644
--- a/private/lib/dao/lib.inclusion.php
+++ b/private/lib/dao/lib.inclusion.php
@@ -17,4 +17,5 @@ require_once(dirname(__FILE__)."/models/NotiziaModel.php");
GenericDao::registerModel("NotiziaModel");
$dao = new GenericDao($database->dbName,$database->connectionString);
+GlobalVariables::set("dao", $dao);
?>
\ No newline at end of file
diff --git a/private/lib/lib.inclusions.php b/private/lib/lib.inclusions.php
index 725f2cd..8234d8a 100644
--- a/private/lib/lib.inclusions.php
+++ b/private/lib/lib.inclusions.php
@@ -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
diff --git a/private/lib/logger/LoggingFacility.php b/private/lib/logger/LoggingFacility.php
index ec7947d..ab2e4ae 100644
--- a/private/lib/logger/LoggingFacility.php
+++ b/private/lib/logger/LoggingFacility.php
@@ -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;
}
diff --git a/private/lib/logger/LoggingFacilityManager.php b/private/lib/logger/LoggingFacilityManager.php
index c99f707..cc30740 100644
--- a/private/lib/logger/LoggingFacilityManager.php
+++ b/private/lib/logger/LoggingFacilityManager.php
@@ -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'");
+ }
}
}
diff --git a/private/lib/system/SFSManager.php b/private/lib/system/SFSManager.php
index 0bdaf63..3b705fb 100644
--- a/private/lib/system/SFSManager.php
+++ b/private/lib/system/SFSManager.php
@@ -8,7 +8,7 @@
*
*/
-class SFSException extends CoreException {}
+class SFSException extends CataloguedException {}
class SFSManager {
diff --git a/private/lib/system/SystemController.php b/private/lib/system/SystemController.php
index e528b22..d3af86f 100644
--- a/private/lib/system/SystemController.php
+++ b/private/lib/system/SystemController.php
@@ -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);
}
diff --git a/private/task/test.php b/private/task/test.php
new file mode 100644
index 0000000..9cd6998
--- /dev/null
+++ b/private/task/test.php
@@ -0,0 +1,23 @@
+#!/usr/bin/php
+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);
+}
+
+?>
\ No newline at end of file
diff --git a/public/index.php b/public/index.php
index 50d6445..ac5eb72 100644
--- a/public/index.php
+++ b/public/index.php
@@ -15,9 +15,10 @@ try {
var_dump($model);
echo "
";
-// $model->immagini = array();
+ $model->immagini = array();
$model->immagini[] = "1.jpg";
+ $model->immagini[] = "2.jpg";
$model->about->giorno = "boh";
var_dump($model);