Skip to content

Commit

Permalink
fixup! Add stage env
Browse files Browse the repository at this point in the history
  • Loading branch information
kostyanf14 committed Sep 11, 2023
1 parent cd2dd1d commit 2f5724f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 71 deletions.
8 changes: 7 additions & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

set :repo_url, 'https://github.com/amnis-invictus/ikt.edu.vn.ua.git'

set :default_env, { path: '$HOME/.rbenv/versions/3.1.2/bin:$PATH' }
set :default_env, { path: '$HOME/.rbenv/shims:$PATH' }

append :linked_files, '.env', 'config/master.key'

append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system', 'storage'

namespace :deploy do
after :finishing, 'application:restart'
after :finishing, 'nginx:reload'
after :finishing, 'bundler:clean'
end
6 changes: 0 additions & 6 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,3 @@
set :rails_env, :production

server 'ikt.codelabs.site:10017', user: 'arch-user', roles: %i[app web db]

namespace :deploy do
after :finishing, 'ikt_application:restart'
after :finishing, 'nginx:reload'
after :finishing, 'bundler:clean'
end
6 changes: 0 additions & 6 deletions config/deploy/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@
append :linked_files, 'config/credentials/staging.key'

server 'stage-ikt.codelabs.site:10016', user: 'arch-user', roles: %i[app web db]

namespace :deploy do
after :finishing, 'stage_application:restart'
after :finishing, 'nginx:reload'
after :finishing, 'bundler:clean'
end
2 changes: 1 addition & 1 deletion config/systemd/ikt.codelabs.site.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Environment = 'RAILS_ENV=production'
Environment = 'SOCKET=unix:///opt/ai/ikt.codelabs.site/current/tmp/sockets/server.sock'
Environment = 'PIDFILE=/opt/ai/ikt.codelabs.site/current/tmp/pids/server.pid'
Environment = 'PATH=/home/arch-user/.rbenv/versions/3.1.2/bin:/usr/local/sbin:/usr/local/bin:/usr/bin'
Environment = 'PATH=/home/arch-user/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/bin'
ExecStart = /usr/bin/env bundle exec puma --config /opt/ai/ikt.codelabs.site/current/config/puma.rb
Restart = always

Expand Down
2 changes: 1 addition & 1 deletion config/systemd/stage-ikt.codelabs.site.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Environment = 'RAILS_ENV=staging'
Environment = 'SOCKET=unix:///opt/ai/stage-ikt.codelabs.site/current/tmp/sockets/server.sock'
Environment = 'PIDFILE=/opt/ai/stage-ikt.codelabs.site/current/tmp/pids/server.pid'
Environment = 'PATH=/home/arch-user/.rbenv/versions/3.1.2/bin:/usr/local/sbin:/usr/local/bin:/usr/bin'
Environment = 'PATH=/home/arch-user/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/bin'
ExecStart = /usr/bin/env bundle exec puma --config /opt/ai/stage-ikt.codelabs.site/current/config/puma.rb
Restart = always

Expand Down
40 changes: 40 additions & 0 deletions lib/capistrano/tasks/application.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace :ikt_application do
desc 'Start application'
task :start do
on roles(:app), in: :sequence, wait: 5 do
within current_path do
if fetch(:rails_env) == 'staging'
execute 'sudo systemctl start stage-ikt.codelabs.site'
else
execute 'sudo systemctl start ikt.codelabs.site'
end
end
end
end

desc 'Stop application'
task :stop do
on roles(:app), in: :sequence, wait: 5 do
within current_path do
if fetch(:rails_env) == 'staging'
execute 'sudo systemctl stop stage-ikt.codelabs.site'
else
execute 'sudo systemctl stop ikt.codelabs.site'
end
end
end
end

desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
within current_path do
if fetch(:rails_env) == 'staging'
execute 'sudo systemctl restart stage-ikt.codelabs.site'
else
execute 'sudo systemctl restart ikt.codelabs.site'
end
end
end
end
end
28 changes: 0 additions & 28 deletions lib/capistrano/tasks/ikt_application.rake

This file was deleted.

28 changes: 0 additions & 28 deletions lib/capistrano/tasks/stage_application.rake

This file was deleted.

0 comments on commit 2f5724f

Please sign in to comment.