capistrano_quick 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +43 -0
- data/lib/capistrano_quick/version.rb +5 -0
- data/lib/capistrano_quick.rb +8 -0
- data/lib/generators/add_capistrano_gems/USAGE +8 -0
- data/lib/generators/add_capistrano_gems/add_capistrano_gems_generator.rb +26 -0
- data/lib/generators/replace_capfile/USAGE +8 -0
- data/lib/generators/replace_capfile/replace_capfile_generator.rb +33 -0
- data/lib/generators/replace_deploy/USAGE +8 -0
- data/lib/generators/replace_deploy/replace_deploy_generator.rb +67 -0
- data/lib/generators/setup_deployment/USAGE +8 -0
- data/lib/generators/setup_deployment/setup_deployment_generator.rb +97 -0
- data/lib/generators/setup_prerequisite/USAGE +8 -0
- data/lib/generators/setup_prerequisite/setup_prerequisite_generator.rb +21 -0
- data/lib/generators/setup_prerequisite/templates/nginx.conf.erb +34 -0
- data/lib/generators/setup_prerequisite/templates/production.rb.erb +5 -0
- data/lib/generators/setup_prerequisite/templates/puma.rb.erb +36 -0
- data/lib/generators/setup_prerequisite/templates/puma.service.erb +13 -0
- data/lib/generators/setup_prerequisite/templates/setup_prerequisite.rake.erb +65 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc10b5d6b80f0b41c01cdb595ed0e8577cdf8911a64b5baf8391c7913f00525c
|
4
|
+
data.tar.gz: 742b7d320092c6720c66c938b12f1660144ff424aa6cdbe8367bf7e638dead37
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ccacdd6da6b0723f9c99c5f053a8357ccf6fe32db18d0b69005ca1c051974f6a1235071471de7e390631e9769f040ce59abfed910690ebb4b4610f725e537eb3
|
7
|
+
data.tar.gz: 96bc6a9c67d0de0697a3e63e66f310f8801d600300e8291395b80b8b6236a6011c6f2cfd0f9fd22fb2b468a82b4344341f338071e37bc00b526047f6dab10766
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# CapistranoQuick
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/capistrano_quick`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
15
|
+
```
|
16
|
+
|
17
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/capistrano_quick. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/capistrano_quick/blob/main/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the CapistranoQuick project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/capistrano_quick/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class AddCapistranoGemsGenerator < Rails::Generators::Base
|
4
|
+
desc "Adds required Capistrano and Figaro gems to the Gemfile"
|
5
|
+
|
6
|
+
def add_gems
|
7
|
+
gemfile_path = "Gemfile"
|
8
|
+
|
9
|
+
append_to_file gemfile_path, <<~GEMS
|
10
|
+
|
11
|
+
gem 'figaro'
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'capistrano'
|
15
|
+
gem 'capistrano3-puma'
|
16
|
+
gem 'capistrano-rails', require: false
|
17
|
+
gem 'capistrano-bundler', require: false
|
18
|
+
gem 'capistrano-rake', require: false
|
19
|
+
gem 'capistrano-rvm'
|
20
|
+
gem 'capistrano-sidekiq'
|
21
|
+
end
|
22
|
+
GEMS
|
23
|
+
|
24
|
+
say "Gems added! Run `bundle install` to install them.", :green
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class ReplaceCapfileGenerator < Rails::Generators::Base
|
4
|
+
desc "Replaces the Capfile with a predefined configuration"
|
5
|
+
|
6
|
+
def replace_capfile
|
7
|
+
capfile_path = "Capfile"
|
8
|
+
|
9
|
+
create_file capfile_path, <<~CAPFILE, force: true
|
10
|
+
require 'capistrano/setup'
|
11
|
+
require 'capistrano/deploy'
|
12
|
+
require 'capistrano/rails'
|
13
|
+
require 'capistrano/bundler'
|
14
|
+
require 'capistrano/rvm'
|
15
|
+
require "capistrano/rails/assets"
|
16
|
+
require "capistrano/rails/migrations"
|
17
|
+
require 'capistrano/puma'
|
18
|
+
require "capistrano/scm/git"
|
19
|
+
require 'capistrano/sidekiq'
|
20
|
+
|
21
|
+
install_plugin Capistrano::SCM::Git
|
22
|
+
install_plugin Capistrano::Puma # Default puma tasks
|
23
|
+
install_plugin Capistrano::Puma::Systemd
|
24
|
+
install_plugin Capistrano::Puma, load_hooks: false
|
25
|
+
install_plugin Capistrano::Sidekiq::Systemd
|
26
|
+
|
27
|
+
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
|
28
|
+
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
|
29
|
+
CAPFILE
|
30
|
+
|
31
|
+
say "Capfile has been replaced successfully!", :green
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
# Commands: rails generate replace_deploy YOUR_CUSTOM_REPO_URL
|
4
|
+
|
5
|
+
class ReplaceDeployGenerator < Rails::Generators::Base
|
6
|
+
desc "Replaces the config/deploy.rb file with a predefined configuration"
|
7
|
+
|
8
|
+
argument :repo_url, type: :string, default: 'git@github.com:expertwatch/bitsatom_emailer.git'
|
9
|
+
|
10
|
+
def replace_deploy
|
11
|
+
deploy_rb_path = "config/deploy.rb"
|
12
|
+
app_name = Rails.application.class.module_parent.to_s.tableize.singularize
|
13
|
+
create_file deploy_rb_path, <<~DEPLOY_RB, force: true
|
14
|
+
# config valid for current version and patch releases of Capistrano
|
15
|
+
lock "~> 3.19.2"
|
16
|
+
|
17
|
+
set :application, "#{app_name}"
|
18
|
+
set :repo_url, "#{repo_url}"
|
19
|
+
set :user, 'deploy'
|
20
|
+
set :puma_threads, [4, 16]
|
21
|
+
set :puma_workers, 0
|
22
|
+
# Don't change these unless you know what you're doing
|
23
|
+
set :pty, true
|
24
|
+
# set :format, :pretty
|
25
|
+
# set :log_level, :debug
|
26
|
+
set :use_sudo, false
|
27
|
+
set :deploy_via, :remote_cache
|
28
|
+
set :deploy_to, "/home/\#{fetch(:user)}/\#{fetch(:application)}"
|
29
|
+
set :puma_bind, "unix://\#{shared_path}/tmp/sockets/puma.sock"
|
30
|
+
set :puma_state, "\#{shared_path}/tmp/pids/puma.state"
|
31
|
+
set :puma_pid, "\#{shared_path}/tmp/pids/puma.pid"
|
32
|
+
set :puma_access_log, "\#{release_path}/log/puma.error.log"
|
33
|
+
set :puma_error_log, "\#{release_path}/log/puma.access.log"
|
34
|
+
set :ssh_options, { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa) }
|
35
|
+
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
|
36
|
+
set :puma_preload_app, true
|
37
|
+
set :puma_worker_timeout, nil
|
38
|
+
set :puma_init_active_record, true # Change to false when not using ActiveRecord
|
39
|
+
|
40
|
+
## Linked Files & Directories (Default None):
|
41
|
+
set :linked_files, %w{config/database.yml}
|
42
|
+
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
|
43
|
+
set :keep_releases, 5
|
44
|
+
set :rvm_type, :user
|
45
|
+
set :rvm_ruby_version, "ruby-3.2.2"
|
46
|
+
set :puma_service_unit_name, "puma"
|
47
|
+
set :puma_systemctl_user, :system
|
48
|
+
|
49
|
+
# In order to set MODE=once
|
50
|
+
set :mode, ENV.fetch('MODE', 'repeat')
|
51
|
+
|
52
|
+
before "deploy:starting", "deploy:setup_prerequisite"
|
53
|
+
|
54
|
+
before 'deploy:starting', 'deploy:set_rails_env'
|
55
|
+
namespace :deploy do
|
56
|
+
desc "Set Rails environment to \#{fetch(:rails_env, 'production')}"
|
57
|
+
task :set_rails_env do
|
58
|
+
on roles(:app) do
|
59
|
+
execute "export RAILS_ENV=\#{fetch(:rails_env, 'production')}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
DEPLOY_RB
|
64
|
+
|
65
|
+
say "config/deploy.rb has been replaced successfully!", :green
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
class SetupDeploymentGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path("templates", __dir__)
|
3
|
+
|
4
|
+
def ask_for_environment
|
5
|
+
# Prompt the user to input either 'production' or 'staging'
|
6
|
+
environment = ask("Please specify the environment (production/staging):", default: "production")
|
7
|
+
|
8
|
+
# Ensure the environment is valid
|
9
|
+
unless ["production", "staging"].include?(environment)
|
10
|
+
say "Invalid environment specified. Defaulting to production.", :red
|
11
|
+
environment = "production"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Set the environment variable
|
15
|
+
@env = environment
|
16
|
+
end
|
17
|
+
|
18
|
+
def ask_for_server
|
19
|
+
@server = ask("Please specify the server (localhost/demo.bitsatom.com/127.0.0.1):", default: "localhost")
|
20
|
+
|
21
|
+
if @server.empty?
|
22
|
+
say "The server cannot be empty, using the default: localhost", :red
|
23
|
+
@server = "localhost"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def ask_for_deploy_user
|
28
|
+
# Prompt the user for the custom deploy user
|
29
|
+
@deploy_user = ask("Please specify the deploy user (e.g., deploy):", default: "ubuntu")
|
30
|
+
|
31
|
+
# Ensure the deploy user is not empty
|
32
|
+
if @deploy_user.empty?
|
33
|
+
say "The deployment path cannot be empty, using the default: ubuntu", :red
|
34
|
+
@deploy_user = "deploy"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def ask_for_app_name
|
39
|
+
# Prompt the user for the custom app_name
|
40
|
+
@app_name = ask("Please specify the app name (e.g., bitsatom_emailer):", default: "bitsatom_emailer")
|
41
|
+
|
42
|
+
# Ensure the path is not empty
|
43
|
+
if @app_name.empty?
|
44
|
+
say "The app name cannot be empty, using the default: bitsatom_emailer", :red
|
45
|
+
@app_name = "bitsatom_emailer"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def run_all_generators
|
50
|
+
# Ask the user for the environment (production/staging)
|
51
|
+
# ask_for_environment
|
52
|
+
# ask_for_app_name
|
53
|
+
# ask_for_deploy_user
|
54
|
+
|
55
|
+
@deploy_path = "/home/#{@deploy_user}"
|
56
|
+
@app_path = "/home/#{@deploy_user}/#{@app_name}"
|
57
|
+
|
58
|
+
ENV["DEPLOY_USER"] = @deploy_user
|
59
|
+
ENV["DEPLOY_PATH"] = @deploy_path
|
60
|
+
ENV["APP_PATH"] = @app_path
|
61
|
+
ENV["ENVIRONMENT"] = @env
|
62
|
+
ENV["SERVER"] = @server
|
63
|
+
|
64
|
+
# Run multiple generators in sequence
|
65
|
+
say "Running generator: add_capistrano_gems"
|
66
|
+
generate "add_capistrano_gems"
|
67
|
+
|
68
|
+
# Run bundle install
|
69
|
+
say "Running: bundle installs"
|
70
|
+
run "bundle install --platform=x86_64-linux"
|
71
|
+
run "bundle install"
|
72
|
+
|
73
|
+
# Ask for confirmation before running cap install with the given environment
|
74
|
+
confirmation = ask("Do you want to run 'cap install STAGES=#{@env}'? (yes/no)", default: "yes")
|
75
|
+
|
76
|
+
if confirmation.downcase == "yes"
|
77
|
+
say "Running: cap install STAGES=#{@env}"
|
78
|
+
run "cap install STAGES=#{@env}"
|
79
|
+
else
|
80
|
+
say "Skipping 'cap install STAGES=#{@env}'", :yellow
|
81
|
+
end
|
82
|
+
|
83
|
+
# Run the remaining generators
|
84
|
+
say "Running generator: replace_capfile"
|
85
|
+
generate "replace_capfile"
|
86
|
+
|
87
|
+
say "Running generator: replace_deploy"
|
88
|
+
generate "replace_deploy"
|
89
|
+
|
90
|
+
say "Running generator: setup_prerequisite"
|
91
|
+
generate "setup_prerequisite"
|
92
|
+
|
93
|
+
say "All generators have been run successfully!"
|
94
|
+
rescue => e
|
95
|
+
say "An error occurred: #{e.message}", :red
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# lib/generators/replace_deploy/setup_prerequisite_generator.rb
|
2
|
+
class SetupPrerequisiteGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("templates", __dir__)
|
4
|
+
|
5
|
+
# This generator will generate the setup_prerequisite.rake file
|
6
|
+
def create_setup_prerequisite_file
|
7
|
+
|
8
|
+
@deploy_user = ENV["DEPLOY_USER"] || "deploy"
|
9
|
+
@deploy_path = ENV["DEPLOY_PATH"] || "/home/deploy"
|
10
|
+
@app_path = ENV["APP_PATH"] || "/home/deploy/app"
|
11
|
+
@env = ENV["ENVIRONMENT"] || "development"
|
12
|
+
@server = ENV["SERVER"] || "localhost"
|
13
|
+
|
14
|
+
|
15
|
+
template "setup_prerequisite.rake.erb", "lib/capistrano/tasks/setup_prerequisite.rake"
|
16
|
+
template "puma.rb.erb","config/deployment/puma.rb"
|
17
|
+
template "puma.service.erb","config/deployment/puma.service"
|
18
|
+
template "production.rb.erb","config/deploy/production.rb"
|
19
|
+
template "nginx.conf.erb","config/deployment/nginx.conf"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
upstream app {
|
2
|
+
# Path to Puma SOCK file, as defined previously
|
3
|
+
server unix://<%=@app_path%>/shared/tmp/sockets/puma.sock fail_timeout=0;
|
4
|
+
}
|
5
|
+
|
6
|
+
server {
|
7
|
+
listen 80;
|
8
|
+
server_name <%= @server %>;
|
9
|
+
|
10
|
+
root <%=@app_path%>/current/public;
|
11
|
+
|
12
|
+
try_files $uri/index.html $uri @app;
|
13
|
+
|
14
|
+
location / {
|
15
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
16
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
17
|
+
proxy_set_header X-Real-IP $remote_addr;
|
18
|
+
proxy_set_header Host $host;
|
19
|
+
proxy_redirect off;
|
20
|
+
proxy_http_version 1.1;
|
21
|
+
proxy_set_header Connection '';
|
22
|
+
proxy_pass http://app;
|
23
|
+
}
|
24
|
+
|
25
|
+
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
|
26
|
+
gzip_static on;
|
27
|
+
expires max;
|
28
|
+
add_header Cache-Control public;
|
29
|
+
}
|
30
|
+
|
31
|
+
error_page 500 502 503 504 /500.html;
|
32
|
+
client_max_body_size 4G;
|
33
|
+
keepalive_timeout 10;
|
34
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env puma
|
2
|
+
|
3
|
+
directory '<%= @app_path %>/current'
|
4
|
+
rackup "<%= @app_path %>/current/config.ru"
|
5
|
+
environment 'production'
|
6
|
+
|
7
|
+
tag ''
|
8
|
+
|
9
|
+
pidfile "<%= @app_path %>/shared/tmp/pids/puma.pid"
|
10
|
+
state_path "<%= @app_path %>/shared/tmp/pids/puma.state"
|
11
|
+
stdout_redirect '<%= @app_path %>/current/log/puma.error.log', '<%= @app_path %>/current/log/puma.access.log', true
|
12
|
+
|
13
|
+
threads 4, 16
|
14
|
+
|
15
|
+
bind 'unix:<%= @app_path %>/shared/tmp/sockets/puma.sock'
|
16
|
+
|
17
|
+
workers 0
|
18
|
+
|
19
|
+
restart_command 'bundle exec puma'
|
20
|
+
|
21
|
+
preload_app!
|
22
|
+
|
23
|
+
on_restart do
|
24
|
+
puts 'Refreshing Gemfile'
|
25
|
+
ENV["BUNDLE_GEMFILE"] = ""
|
26
|
+
end
|
27
|
+
|
28
|
+
before_fork do
|
29
|
+
ActiveRecord::Base.connection_pool.disconnect!
|
30
|
+
end
|
31
|
+
|
32
|
+
on_worker_boot do
|
33
|
+
ActiveSupport.on_load(:active_record) do
|
34
|
+
ActiveRecord::Base.establish_connection
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Puma HTTP Server
|
3
|
+
After=network.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
User=<%= @deploy_user %>
|
8
|
+
WorkingDirectory=<%= @app_path %>/current
|
9
|
+
ExecStart=/home/<%= @deploy_user %>/.rvm/bin/rvm ruby-3.2.2 do bundle exec puma -C <%= @app_path %>/shared/puma.rb
|
10
|
+
Restart=always
|
11
|
+
|
12
|
+
[Install]
|
13
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# lib/generators/replace_deploy/templates/setup_prerequisite.rake
|
2
|
+
namespace :deploy do
|
3
|
+
desc "Upload and configure Nginx"
|
4
|
+
task :setup_prerequisite do
|
5
|
+
on roles(:web) do
|
6
|
+
|
7
|
+
unless test("which git")
|
8
|
+
info "git not found, installing..."
|
9
|
+
execute :sudo, "apt-get install git"
|
10
|
+
else
|
11
|
+
info "git already exists, skipping..."
|
12
|
+
end
|
13
|
+
|
14
|
+
unless test("which nginx")
|
15
|
+
info "nginx not found, installing..."
|
16
|
+
execute :sudo, "apt-get install -y nginx"
|
17
|
+
else
|
18
|
+
info "nginx already exists, skipping..."
|
19
|
+
end
|
20
|
+
|
21
|
+
unless test("which node")
|
22
|
+
info "Node.js not found, installing..."
|
23
|
+
execute :sudo, "apt update"
|
24
|
+
execute :sudo, "apt install -y nodejs"
|
25
|
+
else
|
26
|
+
info "Node.js is already installed"
|
27
|
+
end
|
28
|
+
|
29
|
+
unless test("which yarn")
|
30
|
+
info "Yarn not found, installing..."
|
31
|
+
execute :sudo, "curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -"
|
32
|
+
execute :sudo, "echo \"deb https://dl.yarnpkg.com/debian/ stable main\" | sudo tee /etc/apt/sources.list.d/yarn.list"
|
33
|
+
execute :sudo, "apt update && sudo apt install -y yarn"
|
34
|
+
else
|
35
|
+
info "Yarn is already installed"
|
36
|
+
end
|
37
|
+
|
38
|
+
if fetch(:mode, 'repeat') == 'once'
|
39
|
+
# Upload the nginx configuration file
|
40
|
+
upload! "config/deployment/nginx.conf", "/tmp/nginx.conf"
|
41
|
+
# Move it to the correct location with sudo
|
42
|
+
execute :sudo, "mv /tmp/nginx.conf /etc/nginx/sites-available/default"
|
43
|
+
# Change Nginx user from www-data to <%= @deploy_user %> using sed
|
44
|
+
info "Changing Nginx user from www-data to <%= @deploy_user %>..."
|
45
|
+
execute :sudo, "sed -i 's/^user\\s\\+www-data;/user <%= @deploy_user %>;/' /etc/nginx/nginx.conf"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Restart nginx to apply changes
|
49
|
+
execute :sudo, "systemctl daemon-reload"
|
50
|
+
execute :sudo, "systemctl restart nginx"
|
51
|
+
|
52
|
+
info "PUMA SETUP STARTED"
|
53
|
+
|
54
|
+
upload! "config/deployment/puma.rb", "/tmp/puma.rb"
|
55
|
+
execute :sudo, "mv /tmp/puma.rb <%= @app_path %>/shared/puma.rb"
|
56
|
+
|
57
|
+
# Upload the puma configuration file
|
58
|
+
upload! "config/deployment/puma.service", "/tmp/puma.service"
|
59
|
+
# Move it to the correct location with sudo
|
60
|
+
execute :sudo, "mv /tmp/puma.service /etc/systemd/system/puma.service"
|
61
|
+
execute :sudo, "systemctl daemon-reload"
|
62
|
+
info "PUMA SETUP END"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano_quick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pavan Agrawal
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Capistrano is a powerful deployment automation tool for Ruby on Rails
|
14
|
+
applications. In this guide, we’ll set up Capistrano with Puma on an AWS EC2 instance
|
15
|
+
to deploy a Rails application smoothly.
|
16
|
+
email:
|
17
|
+
- pavan.agrawala@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- README.md
|
23
|
+
- lib/capistrano_quick.rb
|
24
|
+
- lib/capistrano_quick/version.rb
|
25
|
+
- lib/generators/add_capistrano_gems/USAGE
|
26
|
+
- lib/generators/add_capistrano_gems/add_capistrano_gems_generator.rb
|
27
|
+
- lib/generators/replace_capfile/USAGE
|
28
|
+
- lib/generators/replace_capfile/replace_capfile_generator.rb
|
29
|
+
- lib/generators/replace_deploy/USAGE
|
30
|
+
- lib/generators/replace_deploy/replace_deploy_generator.rb
|
31
|
+
- lib/generators/setup_deployment/USAGE
|
32
|
+
- lib/generators/setup_deployment/setup_deployment_generator.rb
|
33
|
+
- lib/generators/setup_prerequisite/USAGE
|
34
|
+
- lib/generators/setup_prerequisite/setup_prerequisite_generator.rb
|
35
|
+
- lib/generators/setup_prerequisite/templates/nginx.conf.erb
|
36
|
+
- lib/generators/setup_prerequisite/templates/production.rb.erb
|
37
|
+
- lib/generators/setup_prerequisite/templates/puma.rb.erb
|
38
|
+
- lib/generators/setup_prerequisite/templates/puma.service.erb
|
39
|
+
- lib/generators/setup_prerequisite/templates/setup_prerequisite.rake.erb
|
40
|
+
homepage: https://github.com/bitsatom/capistrano_quick
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata:
|
44
|
+
homepage_uri: https://github.com/bitsatom/capistrano_quick
|
45
|
+
source_code_uri: https://github.com/bitsatom/capistrano_quick
|
46
|
+
changelog_uri: https://github.com/bitsatom/capistrano_quick
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 3.0.0
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.5.23
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Deploying Rails with Capistrano & Puma on AWS EC2
|
66
|
+
test_files: []
|