From d2cb86bd4b33a3c2ff2d498da2b76ed7ca87d8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Sat, 14 Apr 2018 20:40:27 +0200 Subject: [PATCH] log to stdout (#73) * log to stdout * fix typo * fixed rsync * let scheduler wait for memcached server * made zammad ports configurable * removed memcached check again * added sleep 10 to scheduler start * debug es reindex * removed sleep 10 * fix repo link --- containers/zammad/Dockerfile | 2 ++ containers/zammad/docker-entrypoint.sh | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/containers/zammad/Dockerfile b/containers/zammad/Dockerfile index e2bbe63..a862055 100644 --- a/containers/zammad/Dockerfile +++ b/containers/zammad/Dockerfile @@ -49,6 +49,8 @@ RUN groupadd -g 1000 ${ZAMMAD_USER} \ && bundle install --without test development mysql \ && contrib/packager.io/fetch_locales.rb \ && sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < config/database.yml.pkgr > config/database.yml \ + && sed -i '/# Use a different logger for distributed setups./a \ \ config.logger = Logger.new(STDOUT)' config/environments/production.rb \ + && sed -i 's/.*scheduler_\(err\|out\).log.*//g' script/scheduler.rb \ && bundle exec rake assets:precompile \ && rm -r tmp/cache \ && chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_TMP_DIR} diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh index e2851d1..4c4082a 100644 --- a/containers/zammad/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -5,13 +5,17 @@ set -e : "${ELASTICSEARCH_HOST:=zammad-elasticsearch}" : "${ELASTICSEARCH_PORT:=9200}" : "${MEMCACHED_HOST:=zammad-memcached}" +: "${MEMCACHED_PORT:=11211}" : "${POSTGRESQL_HOST:=zammad-postgresql}" +: "${POSTGRESQL_PORT:=5432}" : "${POSTGRESQL_USER:=postgres}" : "${POSTGRESQL_PASS:=}" : "${POSTGRESQL_DB:=zammad_production}" : "${POSTGRESQL_DB_CREATE:=true}" : "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}" +: "${ZAMMAD_RAILSSERVER_PORT:=3000}" : "${ZAMMAD_WEBSOCKET_HOST:=zammad-websocket}" +: "${ZAMMAD_WEBSOCKET_PORT:=6042}" : "${NGINX_SERVER_NAME:=_}" function check_zammad_ready { @@ -26,19 +30,21 @@ function check_zammad_ready { if [ "$1" = 'zammad-init' ]; then # install / update zammad test -f ${ZAMMAD_READY_FILE} && rm ${ZAMMAD_READY_FILE} - rsync -a --delete --exclude 'storage/fs/*' --exclude 'public/assets/images/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR} + rsync -a --delete --exclude 'public/assets/images/*' --exclude 'storage/fs/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR} rsync -a ${ZAMMAD_TMP_DIR}/public/assets/images/ ${ZAMMAD_DIR}/public/assets/images - until (echo > /dev/tcp/${POSTGRESQL_HOST}/5432) &> /dev/null; do + until (echo > /dev/tcp/${POSTGRESQL_HOST}/${POSTGRESQL_PORT}) &> /dev/null; do echo "zammad railsserver waiting for postgresql server to be ready..." sleep 5 done cd ${ZAMMAD_DIR} - # configure database & cache + # configure database sed -e "s#.*adapter:.*# adapter: postgresql#g" -e "s#.*database:.*# database: ${POSTGRESQL_DB}#g" -e "s#.*username:.*# username: ${POSTGRESQL_USER}#g" -e "s#.*password:.*# password: ${POSTGRESQL_PASS}\n host: ${POSTGRESQL_HOST}\n#g" < config/database.yml.pkgr > config/database.yml - sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/ config.cache_store = :dalli_store, '${MEMCACHED_HOST}:11211'\n config.session_store = :dalli_store, '${MEMCACHED_HOST}:11211'/" config/application.rb + + # configure memcache + sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/ config.cache_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'\n config.session_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'/" config/application.rb echo "initialising / updating database..." # db mirgrate @@ -70,6 +76,7 @@ if [ "$1" = 'zammad-init' ]; then done if [ -z "$(curl -s ${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices |grep zammad)" ]; then + curl -s ${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices echo "rebuilding es searchindex..." bundle exec rake searchindex:rebuild fi @@ -87,7 +94,7 @@ if [ "$1" = 'zammad-nginx' ]; then # configure nginx if [ -z "$(env|grep KUBERNETES)" ]; then - sed -e "s#server .*:3000#server ${ZAMMAD_RAILSSERVER_HOST}:3000#g" -e "s#server .*:6042#server ${ZAMMAD_WEBSOCKET_HOST}:6042#g" -e "s#server_name .*#server_name ${NGINX_SERVER_NAME};#g" -e 's#/var/log/nginx/zammad.\(access\|error\).log#/dev/stdout#g' < contrib/nginx/zammad.conf > /etc/nginx/sites-enabled/default + sed -e "s#server .*:3000#server ${ZAMMAD_RAILSSERVER_HOST}:${ZAMMAD_RAILSSERVER_PORT}#g" -e "s#server .*:6042#server ${ZAMMAD_WEBSOCKET_HOST}:${ZAMMAD_WEBSOCKET_PORT}#g" -e "s#server_name .*#server_name ${NGINX_SERVER_NAME};#g" -e 's#/var/log/nginx/zammad.\(access\|error\).log#/dev/stdout#g' < contrib/nginx/zammad.conf > /etc/nginx/sites-enabled/default fi echo "starting nginx..." @@ -104,7 +111,7 @@ if [ "$1" = 'zammad-railsserver' ]; then echo "starting railsserver..." - exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec rails server puma -b [::] -p 3000 -e ${RAILS_ENV} + exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec rails server puma -b [::] -p ${ZAMMAD_RAILSSERVER_PORT} -e ${RAILS_ENV} fi @@ -128,5 +135,5 @@ if [ "$1" = 'zammad-websocket' ]; then echo "starting websocket server..." - exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 -p 6042 start + exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 -p ${ZAMMAD_WEBSOCKET_PORT} start fi