You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2019/05/01 18:08:35 UTC

[pulsar] branch master updated: Allow to configure Postgres in pulsar dashboard with a docker volume (#4123)

This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 30674dd  Allow to configure Postgres in pulsar dashboard with a docker volume (#4123)
30674dd is described below

commit 30674ddcd04278def71bc49c491d3154301d7582
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Wed May 1 11:08:30 2019 -0700

    Allow to configure Postgres in pulsar dashboard with a docker volume (#4123)
---
 dashboard/Dockerfile                               | 12 +++-------
 dashboard/conf/postgresql.conf                     |  2 +-
 dashboard/conf/supervisor-app.conf                 | 20 ----------------
 .../{conf/postgresql.conf => init-postgres.sh}     | 28 +++++++++-------------
 dashboard/{conf/postgresql.conf => start.sh}       | 21 ++++------------
 5 files changed, 20 insertions(+), 63 deletions(-)

diff --git a/dashboard/Dockerfile b/dashboard/Dockerfile
index b7c8bdd..01c84ea 100644
--- a/dashboard/Dockerfile
+++ b/dashboard/Dockerfile
@@ -39,19 +39,13 @@ COPY conf/supervisor-app.conf /etc/supervisor/conf.d/
 RUN mkdir /pulsar
 COPY . /pulsar/
 
-# Setup database and create tables
-RUN sudo -u postgres /etc/init.d/postgresql start && \
-    sudo -u postgres psql --command "CREATE USER docker WITH PASSWORD 'docker';" && \
-    sudo -u postgres createdb -O docker pulsar_dashboard && \
-    cd /pulsar/django && \
-    ./manage.py migrate && \
-    sudo -u postgres /etc/init.d/postgresql stop
-
 # Collect all static files needed by Django in a
 # single place. Needed to run the app outside the
 # Django test web server
 RUN cd /pulsar/django && ./manage.py collectstatic --no-input
 
+RUN mkdir /data
+
 EXPOSE 80
 
-CMD ["supervisord", "-n"]
+CMD ["/pulsar/start.sh"]
diff --git a/dashboard/conf/postgresql.conf b/dashboard/conf/postgresql.conf
index 201dbba..aabad0d 100644
--- a/dashboard/conf/postgresql.conf
+++ b/dashboard/conf/postgresql.conf
@@ -23,7 +23,7 @@ full_page_writes = off
 synchronous_commit = off
 
 # Default configs
-data_directory = '/var/lib/postgresql/9.6/main'
+data_directory = '/data'
 hba_file = '/etc/postgresql/9.6/main/pg_hba.conf'
 ident_file = '/etc/postgresql/9.6/main/pg_ident.conf'
 external_pid_file = '/var/run/postgresql/9.6-main.pid'
diff --git a/dashboard/conf/supervisor-app.conf b/dashboard/conf/supervisor-app.conf
index 8f6cd00..1a435cc 100644
--- a/dashboard/conf/supervisor-app.conf
+++ b/dashboard/conf/supervisor-app.conf
@@ -17,26 +17,6 @@
 # under the License.
 #
 
-[program:postgres]
-command=/usr/lib/postgresql/9.6/bin/postgres -D /etc/postgresql/9.6/main
-user = postgres
-autostart=true
-autorestart=true
-startsecs=5
-stopasgroup=true
-killasgroup=true
-stopsignal=TERM
-log_stdout=true
-log_stderr=true
-priority=500
-stdout_logfile=/var/log/supervisor/postgres.log
-stderr_logfile=/var/log/supervisor/postgres-error.log
-stdout_logfile_maxbytes=50MB
-stdout_logfile_backups=2
-stderr_logfile_maxbytes=50MB
-stderr_logfile_backups=2
-
-
 [program:uwsgi]
 command=/usr/local/bin/uwsgi --ini /pulsar/conf/uwsgi.ini
 autostart=true
diff --git a/dashboard/conf/postgresql.conf b/dashboard/init-postgres.sh
old mode 100644
new mode 100755
similarity index 59%
copy from dashboard/conf/postgresql.conf
copy to dashboard/init-postgres.sh
index 201dbba..064b7e3
--- a/dashboard/conf/postgresql.conf
+++ b/dashboard/init-postgres.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,22 +18,15 @@
 # under the License.
 #
 
-# Relax durability to increase write throughput
-fsync = off
-full_page_writes = off
-synchronous_commit = off
+set -x -e
 
-# Default configs
-data_directory = '/var/lib/postgresql/9.6/main'
-hba_file = '/etc/postgresql/9.6/main/pg_hba.conf'
-ident_file = '/etc/postgresql/9.6/main/pg_ident.conf'
-external_pid_file = '/var/run/postgresql/9.6-main.pid'
+rm -rf /data/*
+chown -R postgres: /data
+chmod 700 /data
+sudo -u postgres /usr/lib/postgresql/9.6/bin/initdb /data/
+sudo -u postgres /etc/init.d/postgresql start
+sudo -u postgres psql --command "CREATE USER docker WITH PASSWORD 'docker';"
+sudo -u postgres createdb -O docker pulsar_dashboard
 
-port = 5432
-max_connections = 100
-
-datestyle = 'iso, mdy'
-default_text_search_config = 'pg_catalog.english'
-stats_temp_directory = '/var/run/postgresql/9.6-main.pg_stat_tmp'
-timezone = 'UTC'
-log_timezone = 'UTC'
+cd /pulsar/django
+./manage.py migrate
diff --git a/dashboard/conf/postgresql.conf b/dashboard/start.sh
old mode 100644
new mode 100755
similarity index 59%
copy from dashboard/conf/postgresql.conf
copy to dashboard/start.sh
index 201dbba..17423f7
--- a/dashboard/conf/postgresql.conf
+++ b/dashboard/start.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -17,22 +18,10 @@
 # under the License.
 #
 
-# Relax durability to increase write throughput
-fsync = off
-full_page_writes = off
-synchronous_commit = off
+echo "Starting Pulsar dasboard"
 
-# Default configs
-data_directory = '/var/lib/postgresql/9.6/main'
-hba_file = '/etc/postgresql/9.6/main/pg_hba.conf'
-ident_file = '/etc/postgresql/9.6/main/pg_ident.conf'
-external_pid_file = '/var/run/postgresql/9.6-main.pid'
+set -e -x
 
-port = 5432
-max_connections = 100
+/pulsar/init-postgres.sh
 
-datestyle = 'iso, mdy'
-default_text_search_config = 'pg_catalog.english'
-stats_temp_directory = '/var/run/postgresql/9.6-main.pg_stat_tmp'
-timezone = 'UTC'
-log_timezone = 'UTC'
+supervisord -n