13 Commits
Author SHA1 Message Date
r.didato 69eb59b93b Typpo 2022-10-04 20:42:00 +02:00
r.didato 4883c53419 Fix click Banner 2022-10-04 20:41:22 +02:00
r.didato a0bafc453f CICD 2022-10-04 19:56:49 +02:00
r.didato b515760e6d Fix config 2022-10-04 19:47:16 +02:00
r.didato ea4e0c0ec3 FromName email 2022-10-02 19:54:26 +02:00
r.didato 3f04905d22 #12 Backup + fix config email 2022-10-02 19:45:09 +02:00
r.didato 0ab6391bf3 #12 2022-10-02 19:16:59 +02:00
r.didato a66dfa8530 CICD 2022-10-02 15:58:36 +02:00
r.didato 09cf83c31b Typo 2022-10-01 20:03:35 +02:00
r.didato aac8e9786d CICD minor 2022-10-01 12:47:32 +02:00
r.didato bcfea0cfad #6 - WIP 2022-10-01 12:42:57 +02:00
r.didato 8a097b5956 #6 - Prima stesura worker 2022-09-29 23:13:55 +02:00
r.didato effeae054e Incrementata dimensione banner top a 150px 2022-09-29 21:42:47 +02:00
35 changed files with 346 additions and 242 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
function exit_func {
echo "SIGTERM detected"
exit 1
}
trap exit_func SIGTERM SIGINT
ASD_BINDIR="/home/${DDNINJA_AUTHOR}/private/${DDNINJA_BUILDNAME}/bin"
mkdir -p "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
mkdir -p "/home/${DDNINJA_AUTHOR}/storage/${DDNINJA_BUILDNAME}/media/"
mkdir -p "/var/log/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}/"
php /home/${DDNINJA_AUTHOR}/private/${DDNINJA_BUILDNAME}/bin/worker.php & wait
exit $?
+83
View File
@@ -0,0 +1,83 @@
<?php
use ASD\ThresholdTimer;
require_once(dirname(__FILE__)."/../load.php");
require_once("/home/ddninja/private/asdphp/lib/core/ThresholdTimer.php");
$timer = new ThresholdTimer(60);
function logInfo(string $msg) {
echo date("Y-m-d H:i")." - ".$msg,PHP_EOL;
}
function execHour() {
return intval(date('i')) == 0;
}
function execDay() {
return execHour() && intval(date('H')) == 3;
}
function getMinuteTasks() {
return [
GenerateAdminActivationMailTask::class,
GenerateUserActivationMailTask::class,
GenerateAdminPasswordRecoveryMailTask::class,
GenerateUserPasswordRecoveryMailTask::class,
MailSendTask::class
];
}
function getHourTasks() {
return [
// NewsletterCheckTask::class,
DeleteOldPasswordResetRequestsTask::class,
UpdateMeteoCacheTask::class,
GenerateCommentiWarningMailTask::class
];
}
function getDailyTasks() {
return [
// SendBackupTask::class
];
}
function execute($taskName) {
try {
if ($taskName::isActive()){
logInfo("Executing task $taskName");
$taskName::execute();
logInfo("Task $taskName executed with success");
}
}
catch (Exception $ex) {
logInfo("Task $taskName failed execution");
var_dump($ex);
}
}
logInfo("Worker STARTED!!");
$count = 1;
while (1) {
logInfo("Executing Minute");
foreach (getMinuteTasks() as $task ) {
execute($task);
}
if (execHour()) {
logInfo("Exec hourly");
foreach (getHourTasks() as $task ) {
execute($task);
}
}
if (execDay()) {
logInfo("Exec Daily");
foreach (getDailyTasks() as $task ) {
execute($task);
}
}
$timer->waitUntilThresholdReached(true);
}
?>
+8 -1
View File
@@ -36,7 +36,7 @@ $currentSystem->apache->user = "var-www";
$currentSystem->apache->group = "var-www"; $currentSystem->apache->group = "var-www";
$currentSystem->apache->workdir = "/var/www"; // Il path in cui inserire la cartella con le pagine html $currentSystem->apache->workdir = "/var/www"; // Il path in cui inserire la cartella con le pagine html
$currentSystem->remoteLocationPath = getenv('ASD_PUBLIC_URL')."/"; $currentSystem->remoteLocationPath = getenv('DDNINJA_PUBLIC_URL')."/";
// Deprecato in quanto CBS2 è stato dismesso // Deprecato in quanto CBS2 è stato dismesso
$backupSystem = new stdClass(); $backupSystem = new stdClass();
@@ -132,4 +132,11 @@ $config->cbs2->serverPort = $cbs2->serverPort;
$config->database = $database; $config->database = $database;
$config->mailer = new stdClass();
$config->mailer->address = "email-smtp.eu-west-1.amazonaws.com";
$config->mailer->port = "587";
$config->mailer->username = "AKIASMB7IW2MQPUP5CXS";
$config->mailer->password = "BHv+82Nns1kIKg99Hx0sjKlEpR+X4+1EgX+ec64n/mBt";
$config->mailer->smtpAuth = true;
?> ?>
+23 -13
View File
@@ -42,21 +42,21 @@ class MailModel extends Model implements FDN_MailInterface{
return parent::__set($attr, $value); return parent::__set($attr, $value);
} }
public function getMailObject(){
$email = new PHPMailer();
$email->CharSet = "UTF-8";
$email->isMail();
$email->From = $this->from; public function getMailObject() {
if ($this->hasProperty("fromName")){ $email = new PHPMailer();
$email->FromName = $this->fromName; $email->CharSet = "UTF-8";
} $email->isMail();
$email->Subject = $this->subject; $email->From = $this->from;
$email->FromName = "I Fatti di Napoli";
$email->Subject = $this->subject;
$email->IsHTML(true); $email->IsHTML(true);
$email->Body = $this->body;
$email->Body = $this->body;
if ($this->hasProperty("altBody")){ if ($this->hasProperty("altBody")){
$email->AltBody = $this->altBody; $email->AltBody = $this->altBody;
} }
@@ -64,14 +64,24 @@ class MailModel extends Model implements FDN_MailInterface{
$email->AltBody = strip_tags($this->body); $email->AltBody = strip_tags($this->body);
} }
$email->AddAddress($this->recipient);
$email->AddAddress($this->recipient);
if ($this->hasProperty("attachment")){ if ($this->hasProperty("attachment")){
$email->AddAttachment( $this->attachment , basename($this->attachment) ); $email->AddAttachment( $this->attachment , basename($this->attachment) );
} }
return $email; $cfg = GlobalVariables::get("config");
}
$email->IsSMTP();
$email->Host = $cfg->mailer->address;
$email->Port = $cfg->mailer->port;
$email->Username = $cfg->mailer->username;
$email->Password = $cfg->mailer->password;
$email->SMTPAuth = $cfg->mailer->smtpAuth;
return $email;
}
public static function getCollectionName(){ public static function getCollectionName(){
return "mail"; return "mail";
+3 -3
View File
@@ -28,9 +28,9 @@ class MenuGenerator {
array("label"=>"Utenti registrati","page"=>"listUsers.php","requires"=>AdminModel::ADMIN_TYPE_NORMALADMIN), array("label"=>"Utenti registrati","page"=>"listUsers.php","requires"=>AdminModel::ADMIN_TYPE_NORMALADMIN),
array("label"=>"Newsletter", "subvoices"=>array( array("label"=>"Newsletter", "subvoices"=>array(
array("label"=>"Nuova","page"=>"editNewsletter.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER), // array("label"=>"Nuova","page"=>"editNewsletter.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER),
array("label"=>"Da inviare","page"=>"pendingNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER), // array("label"=>"Da inviare","page"=>"pendingNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER),
array("label"=>"Inviate","page"=>"sentNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER), // array("label"=>"Inviate","page"=>"sentNewsletters.php","requires"=>AdminModel::ADMIN_TYPE_NEWSLETTER),
array("label"=>"Nuova Mail","page"=>"editMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN), array("label"=>"Nuova Mail","page"=>"editMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN),
array("label"=>"Coda Mail","page"=>"listMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN) array("label"=>"Coda Mail","page"=>"listMail.php","requires"=>AdminModel::ADMIN_TYPE_SUPERADMIN)
)), )),
+1 -1
View File
@@ -74,7 +74,7 @@ HTMLHelper::generateAdminHead();
<li>Banner testata:<b>180x60px</b></li> <li>Banner testata:<b>180x60px</b></li>
<li>Banner corpo:<b>160x120px</b></li> <li>Banner corpo:<b>160x120px</b></li>
<li>Banner lungo:<b>160x240px</b></li> <li>Banner lungo:<b>160x240px</b></li>
<li>Banner Inizio pagina:<b>1000x120px</b></li> <li>Banner Inizio pagina:<b>1000x150px</b></li>
<li>Banner Fine pagina:<b>1000x200px</b></li> <li>Banner Fine pagina:<b>1000x200px</b></li>
</ul> </ul>
Tale restizione &egrave; consigliata anche per i banner di tipo <i>HTML5</i>. Tale restizione &egrave; consigliata anche per i banner di tipo <i>HTML5</i>.
+22 -1
View File
@@ -41,7 +41,28 @@ function bannerGroup(group, grpName) {
(target) => { (target) => {
if (rval.length > 0) { if (rval.length > 0) {
const ele = rval.shift(); const ele = rval.shift();
$('#'+target).html(ele.media); let mediaHtml = ele.media;
if (ele.link) {
const a = document.createElement('a');
a.href = ele.link;
a.target = "_blank";
a.innerHTML = ele.media;
mediaHtml = a;
}
mediaHtml.click(
() => {
$.ajax({
url: "stats/bannerClick.php",
method: "POST",
data: {
banner: ele.id,
source: document.URL
},
dataType: "html"
});
}
);
$('#'+target).html(mediaHtml);
} }
} }
); );
+1 -1
View File
@@ -28,7 +28,7 @@ body{font-family:lato, arial;}
.rightBanner{position:absolute;top:45px;right:10px;} .rightBanner{position:absolute;top:45px;right:10px;}
.topBanner{width:180px;height:60px;} .topBanner{width:180px;height:60px;}
.topBanner > * { max-width:100%; max-height:100%; } .topBanner > * { max-width:100%; max-height:100%; }
.subheadBanner { width:1000px; height:120px; } .subheadBanner { width:1000px; height:150px; }
.footerBanner { width:1000px; height:200px; } .footerBanner { width:1000px; height:200px; }
+13
View File
@@ -0,0 +1,13 @@
FROM alpine:3.6
RUN apk add --no-cache --upgrade bash mongodb-tools
# copy crontabs for root user
COPY crontab /etc/crontabs/root
# copy backup script
COPY backup /myscripts/backup
RUN chmod 0744 /myscripts/backup
# start crond with log level 8 in foreground, output to stderr
CMD ["crond", "-f", "-d", "8"]
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
DATE=`date +"%Y-%m-%d_%H:%M"`
echo "Generating backup $DATE"
DATABASE_HOST="fdn2.production.database"
DATABASE_NAME="fdn2"
DATABASE_PORT="27017"
WORKDIR="/workdir"
STORAGE="/backups"
mkdir -p $WORKDIR
mongodump --host $DATABASE_HOST -d $DATABASE_NAME --port $DATABASE_PORT --out "$WORKDIR"
tar -cvzf "$STORAGE/dump-$DATE.tar.gz" "$WORKDIR"
for old in `ls -t $STORAGE | tail -n +7`; do
TOREMOVE="$STORAGE/$old"
echo "Removing '$TOREMOVE'";
rm -r $TOREMOVE
done
+1
View File
@@ -0,0 +1 @@
4 0 * * * /myscripts/backup 2>&1
+17
View File
@@ -0,0 +1,17 @@
version: "3"
services:
backup:
image: cronjob
build: ./
networks:
- backup-network
restart: "unless-stopped"
volumes:
- /home/ddninja/fdn2/backups:/backups
networks:
backup-network:
external: true
name:
backup-network
+35 -17
View File
@@ -5,8 +5,11 @@ services:
restart: "on-failure:5" restart: "on-failure:5"
networks: networks:
db-network: db-network:
backup-network:
aliases:
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.database
volumes: volumes:
- ./persistence/database/mongodb:/usr/local/mongodb - ./persistence/database/mongodb:/data/db/
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
@@ -30,7 +33,7 @@ services:
links: links:
- mongo:database - mongo:database
volumes: volumes:
- ./persistence/webserver/storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§ - ./persistence/storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-ws-log:/var/log/§PROJECT_AUTHOR§/ - §PROJECT_BUILDNAME§-ws-log:/var/log/§PROJECT_AUTHOR§/
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - §PROJECT_BUILDNAME§-job-comms:/jobComunication/
logging: logging:
@@ -38,23 +41,32 @@ services:
options: options:
max-file: "5" max-file: "5"
max-size: "150m" max-size: "150m"
# worker: worker:
# image: 662348923997.dkr.ecr.eu-west-1.amazonaws.com/§PROJECT_GROUP§/edenlandia-worker:§TAG_NAME§ image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-worker
# env_file: worker.env env_file:
# restart: "no" - environments/common/worker.env
# networks: - environments/§ENVIRONMENT_TYPE§/worker.env
# db-network: depends_on:
# §PROJECT_BUILDNAME§-network: - mongo
# links: - memcached
# - mongo:database restart: "on-failure:3"
# volumes: networks:
# - §PROJECT_BUILDNAME§-storage:/home/asdynamics/storage/edenlandia-worker db-network:
# - edenlandia-worker-log:/var/log/asdynamics/ §PROJECT_BUILDNAME§-network:
# - ~/workspace-azzurro/webapps/edenlandia-worker/app/private:/home/asdynamics/private/§PROJECT_BUILDNAME§:ro links:
# - §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - mongo:database
volumes:
- ./persistence/storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-wk-log:/var/log/§PROJECT_AUTHOR§/
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "150m"
memcached: memcached:
image: memcached:1.6.9-alpine image: memcached:1.6.9-alpine
restart: "on-failure:3" restart: "on-failure:5"
networks: networks:
§PROJECT_BUILDNAME§-network: §PROJECT_BUILDNAME§-network:
logging: logging:
@@ -66,6 +78,10 @@ services:
networks: networks:
db-network: db-network:
§PROJECT_BUILDNAME§-network: §PROJECT_BUILDNAME§-network:
backup-network:
external: true
name:
backup-network
nginx-network: nginx-network:
external: true external: true
name: name:
@@ -74,5 +90,7 @@ networks:
volumes: volumes:
§PROJECT_BUILDNAME§-ws-log: §PROJECT_BUILDNAME§-ws-log:
§PROJECT_BUILDNAME§-wk-log:
§PROJECT_BUILDNAME§-db-persist: §PROJECT_BUILDNAME§-db-persist:
§PROJECT_BUILDNAME§-job-comms: §PROJECT_BUILDNAME§-job-comms:
+24 -18
View File
@@ -5,12 +5,13 @@ services:
restart: "no" restart: "no"
networks: networks:
db-network: db-network:
backup-network:
aliases: aliases:
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.database - §PROJECT_BUILDNAME§.local.database
volumes: volumes:
- §PROJECT_BUILDNAME§-db-persist:/usr/local/mongodb - §PROJECT_BUILDNAME§-db-persist:/data/db/
webserver: webserver:
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-debug image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-webserver-debug
env_file: env_file:
- environments/common/webserver.env - environments/common/webserver.env
- environments/local/webserver.env - environments/local/webserver.env
@@ -28,20 +29,22 @@ services:
- §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro - §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro
- §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro - §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - §PROJECT_BUILDNAME§-job-comms:/jobComunication/
# worker: worker:
# image: 662348923997.dkr.ecr.eu-west-1.amazonaws.com/§PROJECT_GROUP§/edenlandia-worker:§TAG_NAME§ image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-worker-debug
# env_file: worker.env env_file:
# restart: "no" - environments/common/worker.env
# networks: - environments/local/worker.env
# db-network: restart: "no"
# §PROJECT_BUILDNAME§-network: networks:
# links: db-network:
# - mongo:database §PROJECT_BUILDNAME§-network:
# volumes: links:
# - §PROJECT_BUILDNAME§-storage:/home/asdynamics/storage/edenlandia-worker - mongo:database
# - edenlandia-worker-log:/var/log/asdynamics/ volumes:
# - ~/workspace-azzurro/webapps/edenlandia-worker/app/private:/home/asdynamics/private/§PROJECT_BUILDNAME§:ro - §PROJECT_BUILDNAME§-storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
# - §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - ./worker-logs:/var/log/§PROJECT_AUTHOR§/
- §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
memcached: memcached:
image: memcached:1.6.9-alpine image: memcached:1.6.9-alpine
restart: "no" restart: "no"
@@ -51,11 +54,14 @@ services:
networks: networks:
db-network: db-network:
§PROJECT_BUILDNAME§-network: §PROJECT_BUILDNAME§-network:
backup-network:
external: true
name:
backup-network
volumes: volumes:
§PROJECT_BUILDNAME§-storage: §PROJECT_BUILDNAME§-storage:
§PROJECT_BUILDNAME§-log: §PROJECT_BUILDNAME§-log:
# edenlandia-worker-log:
§PROJECT_BUILDNAME§-db-persist: §PROJECT_BUILDNAME§-db-persist:
§PROJECT_BUILDNAME§-job-comms: §PROJECT_BUILDNAME§-job-comms:
+2 -2
View File
@@ -1,5 +1,5 @@
# Use a PHP runtime as a parent image # Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-webserver
# Set the working directory to /app # Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
@@ -27,7 +27,7 @@ COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install webserver
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
+2 -2
View File
@@ -1,5 +1,5 @@
# Use a PHP runtime as a parent image # Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-webserver
# Set the working directory to /app # Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
@@ -27,7 +27,7 @@ COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install webserver
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
+2 -2
View File
@@ -1,4 +1,4 @@
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§-unit FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-webserver-unit
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
COPY ./app /§PROJECT_BUILDNAME§ COPY ./app /§PROJECT_BUILDNAME§
@@ -9,7 +9,7 @@ COPY ./test/install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install webserver
ENTRYPOINT ["/usr/local/bin/phpunit"] ENTRYPOINT ["/usr/local/bin/phpunit"]
CMD ["--help"] CMD ["--help"]
+2 -2
View File
@@ -1,5 +1,5 @@
# Use a PHP runtime as a parent image # Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-worker
# Set the working directory to /app # Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
@@ -27,7 +27,7 @@ COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install worker
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
+2 -2
View File
@@ -1,5 +1,5 @@
# Use a PHP runtime as a parent image # Use a PHP runtime as a parent image
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§ FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-worker
# Set the working directory to /app # Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
@@ -27,7 +27,7 @@ COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install worker
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"] ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
+2 -2
View File
@@ -1,4 +1,4 @@
FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-§FRAMEWORK_TYPE§-unit FROM §FRAMEWORK_REPOSITORY§/§FRAMEWORK_IMAGE§:§FRAMEWORK_VERSION§-worker-unit
WORKDIR /§PROJECT_BUILDNAME§ WORKDIR /§PROJECT_BUILDNAME§
COPY ./app /§PROJECT_BUILDNAME§ COPY ./app /§PROJECT_BUILDNAME§
@@ -9,7 +9,7 @@ COPY ./test/install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install RUN /§PROJECT_BUILDNAME§/install worker
ENTRYPOINT ["/usr/local/bin/phpunit"] ENTRYPOINT ["/usr/local/bin/phpunit"]
CMD ["--help"] CMD ["--help"]
+3
View File
@@ -0,0 +1,3 @@
DDNINJA_PROJECTNAME=FDN2
DDNINJA_BUILDNAME=fdn2
DDNINJA_AUTHOR=ddninja
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=local
DDNINJA_IS_PRODUCTION=false
DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://www.fdn2.loc:8800
+1 -1
View File
@@ -4,4 +4,4 @@ DDNINJA_IS_PRODUCTION=true
DDNINJA_MONGO_DBNAME=fdn2 DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://preproduction.ifattidinapoli.it DDNINJA_PUBLIC_URL=http://www.ifattidinapoli.it
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=production
DDNINJA_IS_PRODUCTION=true
DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://www.ifattidinapoli.it
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=test
DDNINJA_IS_PRODUCTION=false
DDNINJA_MONGO_DBNAME=fdn2_test
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://test.ifattidinapoli.it
-2
View File
@@ -4,7 +4,6 @@ declare -A CONFIG=(
["FRAMEWORK_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com" ["FRAMEWORK_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com"
["FRAMEWORK_IMAGE"]="ddninja/phpframework" ["FRAMEWORK_IMAGE"]="ddninja/phpframework"
["FRAMEWORK_VERSION"]="2.5.4" ["FRAMEWORK_VERSION"]="2.5.4"
["FRAMEWORK_TYPE"]="webserver"
["FRAMEWORK_AUTHOR"]="ddninja" ["FRAMEWORK_AUTHOR"]="ddninja"
["PROJECT_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com" ["PROJECT_REPOSITORY"]="299952237278.dkr.ecr.eu-west-1.amazonaws.com"
@@ -23,7 +22,6 @@ declare -A CONFIG=(
FRAMEWORK_REPOSITORY=${CONFIG['FRAMEWORK_REPOSITORY']} FRAMEWORK_REPOSITORY=${CONFIG['FRAMEWORK_REPOSITORY']}
FRAMEWORK_IMAGE=${CONFIG['FRAMEWORK_IMAGE']} FRAMEWORK_IMAGE=${CONFIG['FRAMEWORK_IMAGE']}
FRAMEWORK_VERSION=${CONFIG['FRAMEWORK_VERSION']} FRAMEWORK_VERSION=${CONFIG['FRAMEWORK_VERSION']}
FRAMEWORK_TYPE=${CONFIG['FRAMEWORK_TYPE']}
FRAMEWORK_AUTHOR=${CONFIG['FRAMEWORK_AUTHOR']} FRAMEWORK_AUTHOR=${CONFIG['FRAMEWORK_AUTHOR']}
PROJECT_REPOSITORY=${CONFIG['PROJECT_REPOSITORY']} PROJECT_REPOSITORY=${CONFIG['PROJECT_REPOSITORY']}
+13 -5
View File
@@ -1,5 +1,11 @@
#!/bin/bash #!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
fi
TYPE=$1
my_dir="$(dirname "$0")" my_dir="$(dirname "$0")"
DIR_RETURN=`pwd` DIR_RETURN=`pwd`
@@ -25,11 +31,13 @@ chown -R www-data:www-data /var/log/$PROJECT_AUTHOR
chmod 0744 /home/$PROJECT_AUTHOR/private/$PROJECT_BUILDNAME/bin/* chmod 0744 /home/$PROJECT_AUTHOR/private/$PROJECT_BUILDNAME/bin/*
# Apache # Apache
cat ./os/000-${PROJECT_TYPE}.template.conf | if [[ $TYPE == "webserver" ]]; then
sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" \ cat ./os/000-${PROJECT_TYPE}.template.conf |
> /etc/apache2/sites-available/000-default.conf sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" \
> /etc/apache2/sites-available/000-default.conf
a2enmod rewrite a2enmod rewrite
fi
# Overwrite opcache default config # Overwrite opcache default config
cat ./os/opcache.template.ini | cat ./os/opcache.template.ini |
@@ -40,7 +48,7 @@ cat ./os/opcache.template.ini |
cat ./os/php.template.ini > /usr/local/etc/php/php.ini cat ./os/php.template.ini > /usr/local/etc/php/php.ini
# Generate Entrypoint # Generate Entrypoint
cp "./os/webserver-entrypoint" "/usr/local/bin/$PROJECT_BUILDNAME-entrypoint" cp "./os/${TYPE}-entrypoint" "/usr/local/bin/$PROJECT_BUILDNAME-entrypoint"
chmod 0744 /usr/local/bin/$PROJECT_BUILDNAME-entrypoint chmod 0744 /usr/local/bin/$PROJECT_BUILDNAME-entrypoint
-18
View File
@@ -1,18 +0,0 @@
#!/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);
// }
?>
-38
View File
@@ -1,38 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
$tasks = array("SendBackupTask");
if (sizeof($tasks)>0){
foreach ($tasks as $taskName){
try {
if ($taskName::isActive()){
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Executing task '".$taskName::getLabel()."' ");
$taskName::execute();
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Task '".$taskName::getLabel()."' completed successfully");
}
}catch (CoreException $ex){
$msg = "Error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
catch (Exception $ex){
$msg = "Unexpected error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
}
}
// 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);
// }
?>
-40
View File
@@ -1,40 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
$tasks = array("NewsletterCheckTask","DeleteOldPasswordResetRequestsTask", "UpdateMeteoCacheTask", "GenerateCommentiWarningMailTask");
if (sizeof($tasks)>0){
foreach ($tasks as $taskName){
try {
if ($taskName::isActive()){
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Executing task '".$taskName::getLabel()."' ");
$taskName::execute();
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Task '".$taskName::getLabel()."' completed successfully");
}
}catch (CoreException $ex){
$msg = "Error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
catch (Exception $ex){
$msg = "Unexpected error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
}
}
// 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);
// }
?>
-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/php
<?php
/*
Author: Riccardo Di Dato
Creation Date: 12/gen/2016
*/
require_once(dirname(__FILE__). "/../load.php");
$tasks = array(
"GenerateAdminActivationMailTask",
"GenerateUserActivationMailTask",
"GenerateAdminPasswordRecoveryMailTask",
"GenerateUserPasswordRecoveryMailTask",
"MailSendTask",
);
if (sizeof($tasks)>0){
foreach ($tasks as $taskName){
try {
if ($taskName::isActive()){
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Executing task '".$taskName::getLabel()."' ");
$taskName::execute();
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_INFO,"Task '".$taskName::getLabel()."' completed successfully");
}
}catch (CoreException $ex){
$msg = "Error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
catch (Exception $ex){
$msg = "Unexpected error while executing task '".$taskName::getLabel()."' with message '".$ex->getMessage()."'";
LoggingFacilityManager::getLogger("task")->log(LoggingFacility::$LEVEL_ERROR,$msg);
}
}
}
?>
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/php
<?php
require_once(dirname(__FILE__). "/../load.php");
?>
-16
View File
@@ -1,16 +0,0 @@
#!/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);
// }
?>
+2 -2
View File
@@ -97,7 +97,7 @@ if [[ $UNIT_MODE -gt 0 ]]; then
OPTS+="v" OPTS+="v"
fi fi
$DIR/generateDockerfile.sh -$OPTS -o $DOCKERFILE $DIR/generateDockerfile.sh -I "${TYPE}" -$OPTS -o $DOCKERFILE
msg "Building project image $TAG" msg "Building project image $TAG"
docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG-unit -f $DOCKERFILE . docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG-unit -f $DOCKERFILE .
@@ -112,7 +112,7 @@ if [[ $DEBUG_MODE -gt 0 ]]; then
OPTS+="v" OPTS+="v"
fi fi
$DIR/generateDockerfile.sh -$OPTS -o $DOCKERFILE $DIR/generateDockerfile.sh -I "${TYPE}" -$OPTS -o $DOCKERFILE
msg "Building project image $TAG" msg "Building project image $TAG"
docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG-debug -f $DOCKERFILE . docker build -t $PROJECT_REPOSITORY/$PROJECT_GROUP/$PROJECT_BUILDNAME:$TAG-debug -f $DOCKERFILE .
+17 -5
View File
@@ -125,10 +125,14 @@ if [[ $UNIT_MODE -eq 1 ]]; then
BUILDOPT+="v" BUILDOPT+="v"
UNITOPT="-v" UNITOPT="-v"
fi fi
msg "running ./build.sh -$BUILDOPT -t $TAG" msg "running ./build.sh -I webserver -$BUILDOPT -t \"$TAG-webserver\""
./build.sh -$BUILDOPT -t $TAG ./build.sh -I webserver -$BUILDOPT -t "$TAG-webserver"
./run-unit.sh $UNITOPT -t $TAG msg "running ./build.sh -I worker -$BUILDOPT -t \"$TAG-worker\""
./build.sh -I worker -$BUILDOPT -t "$TAG-worker"
./run-unit.sh $UNITOPT -t $TAG-webserver
./run-unit.sh $UNITOPT -t $TAG-worker
fi fi
if [[ $PUBLISH_MODE -eq 1 ]]; then if [[ $PUBLISH_MODE -eq 1 ]]; then
@@ -151,7 +155,13 @@ if [[ $PUBLISH_MODE -eq 1 ]]; then
./publish.sh $VERBOPT -t "$TAG-webserver" ./publish.sh $VERBOPT -t "$TAG-webserver"
# WORKER
msg "running ./build.sh -I worker -$BUILDOPT -t $TAG-worker"
./build.sh -I worker -$BUILDOPT -t "$TAG-worker"
./run-unit.sh $VERBOPT -t "$TAG-worker"
./publish.sh $VERBOPT -t "$TAG-worker"
if [[ $TAG_IMPLICIT -ne 1 ]]; then if [[ $TAG_IMPLICIT -ne 1 ]]; then
git tag $TAG git tag $TAG
@@ -165,8 +175,10 @@ if [[ $DEBUG_MODE -eq 1 ]]; then
if [[ $VERBOSE -gt 0 ]]; then if [[ $VERBOSE -gt 0 ]]; then
BUILDOPT+="v" BUILDOPT+="v"
fi fi
msg "running ./build.sh -$BUILDOPT -t $TAG" msg "running ./build.sh -I webserver -$BUILDOPT -t $TAG-webserver"
./build.sh -$BUILDOPT -t $TAG ./build.sh -$BUILDOPT -I webserver -t $TAG-webserver
msg "running ./build.sh -I worker -$BUILDOPT -t $TAG-worker"
./build.sh -$BUILDOPT -I worker -t $TAG-worker
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/local" OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/local"
mkdir -p $OUT_FOLDER mkdir -p $OUT_FOLDER