From ce6113f6fab3d9f27c774130c5f0e03c047e0df8 Mon Sep 17 00:00:00 2001 From: Panagiotis Koutsourakis <kutsurak@monetdbsolutions.com> Date: Mon, 11 Apr 2016 17:12:00 +0200 Subject: [PATCH] fix various bugs with the initialization --- Dockerfile | 17 ++++++----------- configs/supervisord.conf | 8 -------- scripts/init-db.sh | 38 +++++++++++++++----------------------- 3 files changed, 21 insertions(+), 42 deletions(-) diff --git a/Dockerfile b/Dockerfile index 82d1417..7f9ec7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # Based on CentOS 7 ############################################################ FROM centos:7 -MAINTAINER Panagiotis Koutsourakis, panagiotis.koutsourakis@monetdbsolutions.com +MAINTAINER Panagiotis Koutsourakis <panagiotis.koutsourakis@monetdbsolutions.com> ####################################################### # Expose ports @@ -44,13 +44,14 @@ RUN groupadd -g 5000 monetdb && \ # Enable MonetDB repo RUN yum install -y http://dev.monetdb.org/downloads/epel/MonetDB-release-epel-1.1-1.monetdb.noarch.rpm +RUN rpm --import http://dev.monetdb.org/downloads/MonetDB-GPG-KEY + # Update & upgrade -RUN yum update -y && \ - yum upgrade -y +RUN yum update -y # Install MonetDB -RUN yum install -y MonetDB-SQL-server5-hugeint-11.21.17 +RUN yum install -y MonetDB-SQL-server5-hugeint RUN yum install -y MonetDB-client # Install the MonetDB/GEOM module RUN yum install -y MonetDB-geom-MonetDB5 @@ -77,15 +78,9 @@ COPY configs/.monetdb /home/monetdb/.monetdb COPY scripts/init-db.sh /home/monetdb/init-db.sh RUN chmod +x /home/monetdb/init-db.sh -# Set the owner to monetdbs -RUN chown -R monetdb:monetdb /home/monetdb - # Init the db in a scipt to allow more than one process to run in the container # We need two: one for monetdbd and one for mserver # The sript will init the database with using the unpreveledged user monetdb -RUN sh /home/monetdb/init-db.sh +RUN su -c 'sh /home/monetdb/init-db.sh' monetdb -####################################################### -# Startup scripts -####################################################### CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/configs/supervisord.conf b/configs/supervisord.conf index e342139..76b557e 100644 --- a/configs/supervisord.conf +++ b/configs/supervisord.conf @@ -8,11 +8,3 @@ user=monetdb priority=1 exitcodes=0 startsecs=0 - -[program:monetdb] -command=monetdb start db -autorestart=false -user=monetdb -priority=2 -exitcodes=1 -startsecs=0 diff --git a/scripts/init-db.sh b/scripts/init-db.sh index bcc076a..003a846 100644 --- a/scripts/init-db.sh +++ b/scripts/init-db.sh @@ -1,44 +1,36 @@ #!/bin/bash -function test_monetdb_connection() { - runuser -l monetdb -c "mclient -d db -s 'SELECT 1'" &> /dev/null - local status=$? - if [ $status -ne 0 ]; then - return 0 - fi - return 1 -} - chown -R monetdb:monetdb /var/monetdb5 -cd /home/monetdb if [ ! -d "/var/monetdb5/dbfarm" ]; then - runuser -l monetdb -c 'monetdbd create /var/monetdb5/dbfarm' + monetdbd create /var/monetdb5/dbfarm else echo "Existing dbfarm found in '/var/monetdb5/dbfarm'" fi -runuser -l monetdb -c 'monetdbd start /var/monetdb5/dbfarm' + +monetdbd start /var/monetdb5/dbfarm + sleep 5 if [ ! -d "/var/monetdb5/dbfarm/db" ]; then - runuser -l monetdb -c 'monetdb create db && \ - monetdb set embedr=true db && \ - monetdb release db' + monetdb create db && \ + monetdb set embedr=true db && \ + monetdb release db else echo "Existing database found in '/var/monetdb5/dbfarm/db'" fi -runuser -l monetdb -c 'monetdb start db' for i in {30..0}; do - echo 'Testing MonetDB connection ' $i - if test_monetdb_connection ; then + echo 'Testing MonetDB connection ' $i + mclient -d db -s 'SELECT 1' &> /dev/null + if [ $? -ne 0 ] ; then echo 'Waiting for MonetDB to start...' sleep 1 - else - echo 'MonetDB is running' - break - fi + else + echo 'MonetDB is running' + break + fi done -if [ "$i" = 0 ]; then +if [ $i -eq 0 ]; then echo >&2 'MonetDB startup failed' exit 1 fi -- GitLab