From 37da9bf3f56fa5ce17b9db2b25a6d8adb2e62144 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Sat, 16 Sep 2023 15:43:59 +0300 Subject: [PATCH] Use ikt.codelabs.site instead of generic application Signed-off-by: Kostiantyn Kostiuk --- config/deploy/production.rb | 2 +- ...pplication.conf => ikt.codelabs.site.conf} | 19 ++++++++++--------- config/systemd/application.service | 17 ----------------- config/systemd/ikt.codelabs.site.service | 17 +++++++++++++++++ lib/capistrano/tasks/application.rake | 6 +++--- 5 files changed, 31 insertions(+), 30 deletions(-) rename config/nginx/{application.conf => ikt.codelabs.site.conf} (66%) delete mode 100644 config/systemd/application.service create mode 100644 config/systemd/ikt.codelabs.site.service diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 43ddf39f..379070cf 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -1,3 +1,3 @@ set :branch, :main -server 'ikt.edu.vn.ua:10017', user: 'arch-user', roles: %i[app web db] +server 'ikt.codelabs.site:10017', user: 'arch-user', roles: %i[app web db] diff --git a/config/nginx/application.conf b/config/nginx/ikt.codelabs.site.conf similarity index 66% rename from config/nginx/application.conf rename to config/nginx/ikt.codelabs.site.conf index d469e564..0487a983 100644 --- a/config/nginx/application.conf +++ b/config/nginx/ikt.codelabs.site.conf @@ -1,9 +1,10 @@ -upstream backend { - server unix:///opt/ai/application/current/tmp/sockets/server.sock fail_timeout=0; +upstream ikt_backend { + server unix:///opt/ai/ikt.codelabs.site/current/tmp/sockets/server.sock fail_timeout=0; } server { listen *:80; + server_name ikt.edu.vn.ua ikt.codelabs.site; return 301 https://$host$request_uri; } @@ -11,16 +12,16 @@ server { listen *:443; server_name ikt.edu.vn.ua ikt.codelabs.site; client_max_body_size 1024M; - root /opt/ai/application/current/public/; - error_log /opt/ai/application/current/log/nginx_errors.log; + root /opt/ai/ikt.codelabs.site/current/public/; + error_log /opt/ai/ikt.codelabs.site/current/log/nginx_errors.log; gzip on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/css application/javascript application/octet-stream; - location @backend { - proxy_pass http://backend; + location @ikt_backend { + proxy_pass http://ikt_backend; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -28,7 +29,7 @@ server { } location /cable { - proxy_pass http://backend; + proxy_pass http://ikt_backend; proxy_set_header Connection Upgrade; proxy_set_header Upgrade websocket; proxy_set_header Host $host; @@ -38,10 +39,10 @@ server { location /assets { expires max; - try_files $uri @backend; + try_files $uri @ikt_backend; } location / { - try_files $uri @backend; + try_files $uri @ikt_backend; } } diff --git a/config/systemd/application.service b/config/systemd/application.service deleted file mode 100644 index 0b1adb40..00000000 --- a/config/systemd/application.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] - Description = IKT Application - After = network.service - -[Service] - User = arch-user - Group = arch-user - WorkingDirectory = /opt/ai/application/current - Environment = 'RAILS_ENV=production' - Environment = 'SOCKET=unix:///opt/ai/application/current/tmp/sockets/server.sock' - Environment = 'PIDFILE=/opt/ai/application/current/tmp/pids/server.pid' - 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/application/current/config/puma.rb - Restart = always - -[Install] - WantedBy = multi-user.target diff --git a/config/systemd/ikt.codelabs.site.service b/config/systemd/ikt.codelabs.site.service new file mode 100644 index 00000000..040b449d --- /dev/null +++ b/config/systemd/ikt.codelabs.site.service @@ -0,0 +1,17 @@ +[Unit] + Description = IKT Application + After = network.service + +[Service] + User = arch-user + Group = arch-user + WorkingDirectory = /opt/ai/ikt.codelabs.site/current + 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/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 + +[Install] + WantedBy = multi-user.target diff --git a/lib/capistrano/tasks/application.rake b/lib/capistrano/tasks/application.rake index 6e740eb9..41980663 100644 --- a/lib/capistrano/tasks/application.rake +++ b/lib/capistrano/tasks/application.rake @@ -3,7 +3,7 @@ namespace :application do task :start do on roles(:app), in: :sequence, wait: 5 do within current_path do - execute 'sudo systemctl start application' + execute 'sudo systemctl start ikt.codelabs.site' end end end @@ -12,7 +12,7 @@ namespace :application do task :stop do on roles(:app), in: :sequence, wait: 5 do within current_path do - execute 'sudo systemctl stop application' + execute 'sudo systemctl stop ikt.codelabs.site' end end end @@ -21,7 +21,7 @@ namespace :application do task :restart do on roles(:app), in: :sequence, wait: 5 do within current_path do - execute 'sudo systemctl restart application' + execute 'sudo systemctl restart ikt.codelabs.site' end end end