Created
August 25, 2016 11:43
-
-
Save universal/479cc8b407755b243369a8dfa7cab803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/home/steam/.rvm/wrappers/ruby-2.3.1/ruby | |
| oldrev, newrev = ARGV | |
| def run(cmd) | |
| exit($?.exitstatus) unless system "umask 002 && #{cmd}" | |
| end | |
| RAILS_ENV = ENV['RAILS_ENV'] || 'production' | |
| use_bundler = File.file? 'Gemfile' | |
| rake_cmd = use_bundler ? 'bundle exec rake' : 'rake' | |
| if use_bundler | |
| bundler_args = ['--deployment'] | |
| BUNDLE_WITHOUT = ENV['BUNDLE_WITHOUT'] || 'development:test' | |
| bundler_args << '--without' << BUNDLE_WITHOUT unless BUNDLE_WITHOUT.empty? | |
| # update gem bundle | |
| run "bundle install #{bundler_args.join(' ')}" | |
| end | |
| if File.file? 'Rakefile' | |
| tasks = [] | |
| num_migrations = `git diff #{oldrev} #{newrev} --diff-filter=A --name-only -z db/migrate`.split("\0").size | |
| # run migrations if new ones have been added | |
| tasks << "db:migrate" if num_migrations > 0 | |
| # precompile assets | |
| changed_assets = `git diff #{oldrev} #{newrev} --name-only -z app/assets`.split("\0") | |
| tasks << "assets:precompile" if changed_assets.size > 0 | |
| run "#{rake_cmd} #{tasks.join(' ')} RAILS_ENV=#{RAILS_ENV}" if tasks.any? | |
| end | |
| # clear cached assets (unversioned/ignored files) | |
| run "git clean -x -f -- public/stylesheets public/javascripts" | |
| # clean unversioned files from vendor/plugins (e.g. old submodules) | |
| run "git clean -d -f -- vendor/plugins" | |
| # set up cron task | |
| run "ln -nfs /home/steam/deploy/ark_monitor/deploy/config/production.schedule config/schedule.rb" | |
| run "bundle exec whenever --update-crontab" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BUNDLE = 'bundle' | |
| RAILS_ENV = 'production' | |
| ROOT = File.expand_path(File.join(File.dirname(__FILE__), %w[../ ../])) | |
| Eye.config do | |
| logger "#{ROOT}/log/eye.log" | |
| end | |
| Eye.application :ark_monitor do | |
| env 'RAILS_ENV' => RAILS_ENV | |
| working_dir ROOT | |
| trigger :flapping, times: 10, within: 1.minute | |
| process 'web-1' do | |
| daemonize true | |
| pid_file 'tmp/puma.pid' | |
| stdall 'log/web-1.log' | |
| start_command "#{BUNDLE} exec puma -b unix://#{ROOT}/tmp/puma.sock" | |
| stop_signals [:TERM, 5.seconds, :KILL] | |
| restart_command 'kill -USR2 {PID}' | |
| # just sleep this until process get up status | |
| # (maybe enough to puma soft restart) | |
| restart_grace 10.seconds | |
| check :cpu, every: 30, below: 80, times: 3 | |
| check :memory, every: 30, below: 200.megabytes, times: [3, 5] | |
| end | |
| process 'delayed-job-1' do | |
| pid_file "tmp/pids/delayed_job.1.pid" | |
| start_command 'bin/delayed_job start -i 1' | |
| stop_command "bin/delayed_job stop -i 1" | |
| restart_command "bin/delayed_job restart -i 1" | |
| stdall "log/delayed-job-1.log" | |
| pid_file 'tmp/pids/delayed_job.1.pid' | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/home/steam/.rvm/wrappers/ruby-2.3.1/ruby | |
| def eye_command(sub_command) | |
| "bundle exec eye #{sub_command}" | |
| end | |
| def run(cmd) | |
| exit($?.exitstatus) unless system "umask 002 && #{cmd}" | |
| end | |
| run eye_command("load deploy/config/production.eye") | |
| run eye_command("restart ark_monitor") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment