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
This commit is contained in:
André Bauer 2018-04-14 20:40:27 +02:00 committed by GitHub
parent 42a76b8752
commit d2cb86bd4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -49,6 +49,8 @@ RUN groupadd -g 1000 ${ZAMMAD_USER} \
&& bundle install --without test development mysql \ && bundle install --without test development mysql \
&& contrib/packager.io/fetch_locales.rb \ && 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 -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 \ && bundle exec rake assets:precompile \
&& rm -r tmp/cache \ && rm -r tmp/cache \
&& chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_TMP_DIR} && chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_TMP_DIR}

View File

@ -5,13 +5,17 @@ set -e
: "${ELASTICSEARCH_HOST:=zammad-elasticsearch}" : "${ELASTICSEARCH_HOST:=zammad-elasticsearch}"
: "${ELASTICSEARCH_PORT:=9200}" : "${ELASTICSEARCH_PORT:=9200}"
: "${MEMCACHED_HOST:=zammad-memcached}" : "${MEMCACHED_HOST:=zammad-memcached}"
: "${MEMCACHED_PORT:=11211}"
: "${POSTGRESQL_HOST:=zammad-postgresql}" : "${POSTGRESQL_HOST:=zammad-postgresql}"
: "${POSTGRESQL_PORT:=5432}"
: "${POSTGRESQL_USER:=postgres}" : "${POSTGRESQL_USER:=postgres}"
: "${POSTGRESQL_PASS:=}" : "${POSTGRESQL_PASS:=}"
: "${POSTGRESQL_DB:=zammad_production}" : "${POSTGRESQL_DB:=zammad_production}"
: "${POSTGRESQL_DB_CREATE:=true}" : "${POSTGRESQL_DB_CREATE:=true}"
: "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}" : "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}"
: "${ZAMMAD_RAILSSERVER_PORT:=3000}"
: "${ZAMMAD_WEBSOCKET_HOST:=zammad-websocket}" : "${ZAMMAD_WEBSOCKET_HOST:=zammad-websocket}"
: "${ZAMMAD_WEBSOCKET_PORT:=6042}"
: "${NGINX_SERVER_NAME:=_}" : "${NGINX_SERVER_NAME:=_}"
function check_zammad_ready { function check_zammad_ready {
@ -26,19 +30,21 @@ function check_zammad_ready {
if [ "$1" = 'zammad-init' ]; then if [ "$1" = 'zammad-init' ]; then
# install / update zammad # install / update zammad
test -f ${ZAMMAD_READY_FILE} && rm ${ZAMMAD_READY_FILE} 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 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..." echo "zammad railsserver waiting for postgresql server to be ready..."
sleep 5 sleep 5
done done
cd ${ZAMMAD_DIR} 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 -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..." echo "initialising / updating database..."
# db mirgrate # db mirgrate
@ -70,6 +76,7 @@ if [ "$1" = 'zammad-init' ]; then
done done
if [ -z "$(curl -s ${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices |grep zammad)" ]; then 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..." echo "rebuilding es searchindex..."
bundle exec rake searchindex:rebuild bundle exec rake searchindex:rebuild
fi fi
@ -87,7 +94,7 @@ if [ "$1" = 'zammad-nginx' ]; then
# configure nginx # configure nginx
if [ -z "$(env|grep KUBERNETES)" ]; then 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 fi
echo "starting nginx..." echo "starting nginx..."
@ -104,7 +111,7 @@ if [ "$1" = 'zammad-railsserver' ]; then
echo "starting railsserver..." 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 fi
@ -128,5 +135,5 @@ if [ "$1" = 'zammad-websocket' ]; then
echo "starting websocket server..." 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 fi