2016-12-17 11:10:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-12-20 12:51:56 +00:00
|
|
|
if [ "$1" = 'zammad' ]; then
|
2016-12-17 11:10:51 +00:00
|
|
|
|
2017-01-06 14:11:05 +00:00
|
|
|
cd ${ZAMMAD_DIR}
|
2017-01-09 17:51:09 +00:00
|
|
|
bundle exec rake db:migrate &> /dev/null
|
2016-12-19 20:26:04 +00:00
|
|
|
|
2017-01-06 14:11:05 +00:00
|
|
|
if [ $? != 0 ]; then
|
2017-01-07 16:03:38 +00:00
|
|
|
echo "creating db & searchindex..."
|
|
|
|
bundle exec rake db:create
|
|
|
|
bundle exec rake db:migrate
|
|
|
|
bundle exec rake db:seed
|
|
|
|
bundle exec rails r "Setting.set('es_url', 'http://elasticsearch:9200')"
|
|
|
|
bundle exec rake searchindex:rebuild
|
2016-12-17 11:10:51 +00:00
|
|
|
fi
|
|
|
|
|
2017-01-06 14:11:05 +00:00
|
|
|
# delete logs & pids
|
2017-01-07 16:03:38 +00:00
|
|
|
rm ${ZAMMAD_DIR}/log/*.log
|
|
|
|
rm ${ZAMMAD_DIR}/tmp/pids/*.pid
|
2016-12-17 11:10:51 +00:00
|
|
|
|
|
|
|
# run zammad
|
|
|
|
echo "starting zammad..."
|
2016-12-17 12:23:29 +00:00
|
|
|
echo "zammad will be accessable on http://localhost in some seconds"
|
2016-12-19 20:26:04 +00:00
|
|
|
bundle exec script/websocket-server.rb -b 0.0.0.0 start &
|
|
|
|
bundle exec script/scheduler.rb start &
|
2016-12-19 20:39:15 +00:00
|
|
|
|
2016-12-19 20:26:04 +00:00
|
|
|
if [ "${RAILS_SERVER}" == "puma" ]; then
|
2017-01-05 13:17:52 +00:00
|
|
|
bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV}
|
2016-12-19 20:26:04 +00:00
|
|
|
elif [ "${RAILS_SERVER}" == "unicorn" ]; then
|
2017-01-05 13:17:52 +00:00
|
|
|
bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV}
|
2016-12-19 20:26:04 +00:00
|
|
|
fi
|
2016-12-17 11:10:51 +00:00
|
|
|
|
2017-01-07 12:52:50 +00:00
|
|
|
if [ "${ZAMMAD_DEBUG}" == "yes" ]; then
|
2016-12-17 11:10:51 +00:00
|
|
|
# keepalive if error
|
|
|
|
while true; do
|
|
|
|
echo "debugging..."
|
|
|
|
sleep 600
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|