Skip to content

Commit

Permalink
Improved restarting zammad after object attribute changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
martini committed May 27, 2016
1 parent 06d6df9 commit 17cbac8
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 120 deletions.
196 changes: 84 additions & 112 deletions .gitlab-ci.yml

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions app/models/object_manager/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,8 @@ def self.migration_execute
if execute_count != 0
if ENV['APP_RESTART_CMD']
AppVersion.set(true, 'restart_auto')
pid = fork do
sleep 5
system(ENV['APP_RESTART_CMD'])
Process.exit!(true)
end
sleep 4
Delayed::Job.enqueue(Observer::AppVersionRestartJob.new(ENV['APP_RESTART_CMD']))
else
AppVersion.set(true, 'restart_manual')
end
Expand All @@ -622,7 +619,7 @@ def check_name
raise 'Only letters from a-z, numbers from 0-9, and _ are allowed'
elsif name !~ /[a-z]/
raise 'At least one letters is needed'
elsif name =~ /^(destroy|true|false|integer|select|drop|create|alter|index|table)$/i
elsif name =~ /^(destroy|true|false|integer|select|drop|create|alter|index|table)$/
raise "#{name} is a reserved word, please choose a different one"
end
true
Expand Down
10 changes: 10 additions & 0 deletions app/models/observer/app_version_restart_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Observer::AppVersionRestartJob
def initialize(cmd)
@cmd = cmd
end

def perform
output = `#{@cmd}`
Rails.logger.info "CMD: #{@cmd} -> #{output}"
end
end
4 changes: 4 additions & 0 deletions script/build/test_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

rake db:drop RAILS_ENV=test
rake db:drop RAILS_ENV=production
7 changes: 5 additions & 2 deletions script/build/test_shutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ RAILS_ENV=$1
APP_PORT=$2
WS_PORT=$3
EXIT=$4 || 0
WITH_DB=$5 || 0

SERVER_PID='tmp/pids/server.pid'

script/scheduler.rb stop
Expand All @@ -13,7 +15,8 @@ if [ -f $SERVER_PID ]; then
kill -9 $(cat $SERVER_PID)
fi

rake db:drop RAILS_ENV=test
rake db:drop RAILS_ENV=production
if WITH_DB; then
script/build/test_cleanup.sh
fi

exit $EXIT
5 changes: 5 additions & 0 deletions script/build/test_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
RAILS_ENV=$1
APP_PORT=$2
WS_PORT=$3
WITH_DB=$4 || 0

if WITH_DB; then
script/bootstrap.sh
fi

export ZAMMAD_SETTING_TTL=15

Expand Down

0 comments on commit 17cbac8

Please sign in to comment.