Skip to content

Commit

Permalink
tasks changed
Browse files Browse the repository at this point in the history
  • Loading branch information
airled committed Feb 7, 2016
1 parent 50e785e commit 2fab06e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 63 deletions.
23 changes: 3 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,21 @@ task :skk do
puts 'Sidekiq killed.'
end

namespace :local do

desc "Start the application locally with Unicorn."
task :start do
system('source ~/.zshrc && bundle exec unicorn -c config/unicorn.rb -E production -D')
puts 'Unicorn started.'
end

desc "Stop the application runned with Unicorn."
task :stop do
pid = File.open('/home/railiner/current/tmp/pids/unicorn.pid') { |f| f.read }
system("kill #{pid.strip}")
puts 'Unicorn killed.'
end

end

namespace :remote do

desc 'Start the remote application with Capistrano.'
task :start do
system('bundle exec cap production app:start')
system('bundle exec cap production start')
end

desc 'Stop the remote application with Capistrano.'
task :stop do
system('bundle exec cap production app:stop')
system('bundle exec cap production stop')
end

desc 'Start reparsing remotely with Capistrano.'
task :reparse do
system('bundle exec cap production app:reparse')
system('bundle exec cap production reparse')
end

end
2 changes: 1 addition & 1 deletion app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1>Railiner</h1>
<hr>

<div>Продукты <%= link_to 'catalog.onliner.by', 'https://catalog.onliner.by' %>. Добро пожаловать!</div>
<div>Продукты <%= link_to 'catalog.onliner.by', 'https://catalog.onliner.by', target: '_blank' %>. Добро пожаловать!</div>
<% if @date %>
<div>База данных от <%= @date %></div>
<% end %>
58 changes: 16 additions & 42 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
# config valid only for current version of Capistrano
lock '3.4.0'
set :default_env, { 'PATH' => '$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH' }
# set :default_shell, '/bin/zsh --login'
set :application, 'railiner'
set :repo_url, '[email protected]:airled/railiner'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/railiner'
set :tmp_dir, '/home/railiner/tmp'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
set :rbenv_type, :user # or :system, depends on your rbenv setup
set :rbenv_type, :user
set :rbenv_ruby, '2.1.5'
# in case you want to set ruby version from the file:
# set :rbenv_ruby, File.read('.ruby-version').strip
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
set :rbenv_roles, :all # default value
Expand All @@ -44,31 +22,27 @@
end
end

namespace :app do

task :start do
on roles(:all) do
within "#{fetch(:deploy_to)}/current/" do
execute :bundle, :exec, :rake, 'local:start'
end
task :start do
on roles(:all) do
within "#{fetch(:deploy_to)}/current/" do
execute 'source ~/.zshrc && cd current && bundle exec unicorn -c config/unicorn.rb -E production -D && echo "Unicorn started"'
end
end
end

task :stop do
on roles(:all) do
within "#{fetch(:deploy_to)}/current/" do
execute :bundle, :exec, :rake, 'local:stop'
end
task :stop do
on roles(:all) do
within "#{fetch(:deploy_to)}/current/" do
execute "pid=$(cat #{fetch(:deploy_to)}/current/tmp/pids/unicorn.pid) && kill -9 $(echo $pid) && echo 'Unicorn killed'"
end
end
end

task :reparse do
on roles(:all) do
within "#{fetch(:deploy_to)}/current/" do
execute :bundle, :exec, :rake, 'reset RAILS_ENV=production'
execute 'source ~/.zshrc && cd current && RAILS_ENV=production bundle exec rake parse\[d\]'
end
task :reparse do
on roles(:all) do
within "#{fetch(:deploy_to)}/current/" do
execute :bundle, :exec, :rake, 'reset RAILS_ENV=production'
execute 'source ~/.zshrc && cd current && RAILS_ENV=production bundle exec rake parse\[d\]'
end
end

end

0 comments on commit 2fab06e

Please sign in to comment.