From e5b7060f63d8c7254460404555a2697eebea3653 Mon Sep 17 00:00:00 2001 From: Paul Caskey Date: Fri, 8 Jan 2021 13:53:46 -0600 Subject: [PATCH] add instance refresh --- Workbench/docker-compose.yml | 2 - Workbench/scripts/refreshListener.php | 28 ++++++++++ Workbench/webproxy/Dockerfile | 10 +++- .../webproxy/container_files/httpd/index.html | 1 + .../container_files/httpd/refresh/index.php | 56 +++++++++++++++++++ 5 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 Workbench/scripts/refreshListener.php create mode 100644 Workbench/webproxy/container_files/httpd/refresh/index.php diff --git a/Workbench/docker-compose.yml b/Workbench/docker-compose.yml index 3ebb492..6fde02a 100644 --- a/Workbench/docker-compose.yml +++ b/Workbench/docker-compose.yml @@ -524,5 +524,3 @@ volumes: generated-config: generated-metadata: mariadb-data: - - diff --git a/Workbench/scripts/refreshListener.php b/Workbench/scripts/refreshListener.php new file mode 100644 index 0000000..3bf9f26 --- /dev/null +++ b/Workbench/scripts/refreshListener.php @@ -0,0 +1,28 @@ +channel(); + +$channel->queue_declare('refreshInstance', false, false, false, false); + +echo " [*] Waiting for messages. To exit press CTRL+C\n"; + +$callback = function ($msg) { + echo ' [x] Received ', $msg->body, "\n"; + if ($msg->body == "REFRESH_THIS_INSTANCE") { + echo "Received REFRESH message!\n"; + shell_exec( "/csp-tap/InCommonTAP-Examples/Workbench/scripts/refresh-this-instance.sh" ); + } +}; + +$channel->basic_consume('refreshInstance', '', false, true, false, false, $callback); + +while ($channel->is_consuming()) { + $channel->wait(); +} + +$channel->close(); +$connection->close(); +?> \ No newline at end of file diff --git a/Workbench/webproxy/Dockerfile b/Workbench/webproxy/Dockerfile index e548133..be0e425 100644 --- a/Workbench/webproxy/Dockerfile +++ b/Workbench/webproxy/Dockerfile @@ -3,9 +3,13 @@ FROM tier/shibboleth_sp:latest ARG CSPHOSTNAME=localhost ENV CSPHOSTNAME=$CSPHOSTNAME -RUN yum -y install cronie +RUN yum -y install cronie php composer php-bcmath +RUN composer require php-amqplib/php-amqplib +RUN composer install +RUN mkdir -p /var/www/html/refresh -#COPY container_files/httpd/httpd.conf /etc/httpd/conf/ + +COPY container_files/httpd/refresh/index.php /var/www/html/refresh/ COPY container_files/httpd/proxy.conf /etc/httpd/conf.d/ COPY container_files/httpd/shib.conf /etc/httpd/conf.d/ COPY container_files/httpd/ssl.conf /etc/httpd/conf.d/ @@ -22,6 +26,8 @@ COPY container_files/shibboleth/ /etc/shibboleth/ COPY container_files/system/setservername.sh /usr/local/bin/ RUN chmod 755 /usr/local/bin/setservername.sh +RUN mkdir -p /signalreload + # fix httpd logging for ssl logs RUN sed -i 's/TransferLog logs\/ssl_access_log/TransferLog \/tmp\/logpipe/g' /etc/httpd/conf.d/ssl.conf \ && sed -i 's/ErrorLog logs\/ssl_error_log/ErrorLog \/tmp\/logpipe/g' /etc/httpd/conf.d/ssl.conf diff --git a/Workbench/webproxy/container_files/httpd/index.html b/Workbench/webproxy/container_files/httpd/index.html index d7862f9..305d221 100644 --- a/Workbench/webproxy/container_files/httpd/index.html +++ b/Workbench/webproxy/container_files/httpd/index.html @@ -40,5 +40,6 @@

Welcome to the InCommon TAP Workbench!




Container Status +Refresh this instance diff --git a/Workbench/webproxy/container_files/httpd/refresh/index.php b/Workbench/webproxy/container_files/httpd/refresh/index.php new file mode 100644 index 0000000..5728466 --- /dev/null +++ b/Workbench/webproxy/container_files/httpd/refresh/index.php @@ -0,0 +1,56 @@ + + + + Refresh Instance + + +
+ + + +Are you sure you want to refresh this instance? It will be unavailable while refreshing. +

+Please type in the hostname of this instance to confirm you want to refresh. +

+ +
"> +Confirmation: +

+ +
+
The refresh will start immediately (" . date("h:i:sa") . " GMT)."; + + + $connection = new AMQPStreamConnection('mq', 5672, 'guest', 'password'); + $channel = $connection->channel(); + + $channel->queue_declare('refreshInstance', false, false, false, false); + + $msg = new AMQPMessage('REFRESH_THIS_INSTANCE'); + $channel->basic_publish($msg, '', 'refreshInstance'); + + $channel->close(); + $connection->close(); + + } else { + echo "Invalid confirmation. Please re-try using your actual hostname."; + } +} +?> + + + \ No newline at end of file