Commit 154a6596 by liyijie

feat: 更新storage的template脚本内容

parent d3cfc4d0
......@@ -3,7 +3,13 @@ SECRET_KEY_BASE =
DATABASE_ADAPTER = postgresql
DATABASE_POOL = 5
DATABASE_HOST = localhost
DATABASE_USERNAME = postgresql
DATABASE_USERNAME = postgres
DATABASE_PASSWORD =
DATABASE_NAME = app_name_to_replace
S3_ACCESS_KEY_ID = n7Xqqp1Fweznus_J0o14DJjuDuuZ-UJYa5lVMnSl
S3_SECRET_ACCESS_KEY = M-M8qDXRjz4wPz0khw9-QSco6yLzaeqNaouaDFP1
S3_REGION = cn-south-1
S3_BUCKET = wechat-peacock
S3_ENDPOINT = https://ocs-cn-south1.heytapcs.com
S3_PUBLIC = true
......@@ -5,10 +5,8 @@ require 'mina/rails'
require 'mina/git'
require 'mina/multistage'
# require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
require 'mina/rvm' # for rvm support. (https://rvm.io)
require 'mina/rvm' # for rvm support. (https://rvm.io)
require 'mina/bundler'
require 'mina/puma'
# require 'mina_sidekiq/tasks'
# Basic settings:
# domain - The hostname to SSH to.
......@@ -16,7 +14,7 @@ require 'mina/puma'
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
set :application_name, 'app_name'
set :application_name, 'education_api'
set :repository, 'https://github.com/app_name.git'
set :branch, 'master'
set :rails_env, 'production'
......@@ -24,7 +22,7 @@ set :rails_env, 'production'
# Optional settings:
# set :user, 'foobar' # Username in the server to SSH to.
# set :port, '30000' # SSH port number.
# set :forward_agent, true # SSH forward_agent.
set :forward_agent, true # SSH forward_agent.
# Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
# Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more
......@@ -35,7 +33,7 @@ set :shared_dirs, fetch(:shared_dirs, []).push('tmp/pids', 'tmp/sockets')
set :shared_files, fetch(:shared_files, []).push('.env.production.local')
# sidekiq
# set :sidekiq_pid, 'tmp/pids/sidekiq.pid'
set :sidekiq_pid, 'tmp/pids/sidekiq.pid'
# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
......@@ -45,7 +43,7 @@ task :remote_environment do
# invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
invoke :'rvm:use', 'ruby-2.4.2'
invoke :'rvm:use', 'ruby-3.0.1'
end
# Put any custom commands you need to run at setup
......@@ -69,7 +67,8 @@ task :deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
command %{rails db:migrate RAILS_ENV=production}
# invoke :'rails:db_create'
command %{bundle exec rails db:migrate RAILS_ENV=production}
# invoke :'rails[db:migrate]'
invoke :'deploy:cleanup'
......@@ -79,12 +78,13 @@ task :deploy do
# command %{touch tmp/restart.txt}
# end
invoke :load
invoke :'puma:stop'
invoke :'puma:start'
# invoke :'sidekiq:restart'
# invoke :'systemctl:restart', fetch(:sidekiq_service_name)
invoke :'systemctl:restart', fetch(:puma_service_name)
end
end
# invoke(:"systemctl:restart['puma-soa-okr']")
# you can use `run :local` to run tasks on local machine before of after the deploy scripts
# run(:local){ say 'done' }
end
......@@ -95,3 +95,25 @@ task :load do
command %{export WEB_CONCURRENCY=#{workers}}
command %{export RAILS_MAX_THREADS=#{threads}}
end
namespace :systemctl do
desc "Start a systemd service"
task :start, [:service] do |t, args|
command %[sudo systemctl start #{args[:service]}]
end
desc "Restart a systemd service"
task :restart, [:service] do |t, args|
command %[sudo systemctl restart #{args[:service]}]
end
desc "Stop a systemd service"
task :stop, [:service] do |t, args|
command %[sudo systemctl stop #{args[:service]}]
end
desc "Get status of a systemd service"
task :status, [:service] do |t, args|
command %[sudo systemctl status #{args[:service]}]
end
end
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
s3:
service: S3
access_key_id: <%= ENV["S3_ACCESS_KEY_ID"] %>
secret_access_key: <%= ENV["S3_SECRET_ACCESS_KEY"] %>
region: <%= ENV["S3_REGION"] %>
bucket: <%= ENV["S3_BUCKET"] %>
endpoint: <%= ENV["S3_ENDPOINT"] %>
public: <%= ENV["S3_PUBLIC"] %>
......@@ -5,14 +5,11 @@ end
# Add needed gem to Gemfile
gsub_file 'Gemfile', 'https://rubygems.org', 'https://gems.ruby-china.com'
inject_into_file 'Gemfile', after: "source 'https://gems.ruby-china.com'" do <<-GEM_COMMENT
# A Ruby gem to load environment variables from `.env`.
# https://github.com/bkeepers/dotenv
# If you use gems that require environment variables to be set before they are loaded, then list dotenv-rails in the Gemfile before those other gems and require dotenv/rails-now.
gem 'dotenv-rails', require: 'dotenv/rails-now'
GEM_COMMENT
end
gem 'pg'
inject_into_file 'Gemfile', before: "gem 'pg" do <<-COMMENT
......@@ -20,34 +17,6 @@ inject_into_file 'Gemfile', before: "gem 'pg" do <<-COMMENT
COMMENT
end
# gem 'jbuilder'
# inject_into_file 'Gemfile', before: "gem 'jbuilder'" do <<-COMMENT
# # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# COMMENT
# end
#
# gem 'rack-cors'
# inject_into_file 'Gemfile', before: "gem 'rack-cors" do <<-COMMENT
# # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# COMMENT
# end
#
# gem 'redis'
gem 'uuid64'
inject_into_file 'Gemfile', before: "gem 'uuid64'" do <<-COMMENT
# This is a library generating unique id in short pattern. https://rubygems.org/gems/uuid64
# https://github.com/heckpsi-lab/uuid64
COMMENT
end
gem 'responders'
inject_into_file 'Gemfile', before: "gem 'responders'" do <<-COMMENT
# A set of Rails responders to dry up your application http://blog.plataformatec.com.br/
# https://github.com/plataformatec/responders
# rails g responders:install
COMMENT
end
gsub_file 'app/controllers/application_controller.rb', 'respond_to :html', 'respond_to :json'
# A Ruby static code analyzer, based on the community Ruby style guide. http://rubocop.readthedocs.io
......@@ -67,7 +36,7 @@ gem 'mina-multistage', require: false
gem 'sprockets'
gem 'rails_com', git: 'https://git.tallty.com/ta-rails/rails_com.git'
gem 'rails_com', git: 'git@git.tallty.com:ta-rails/rails_com.git'
gem_group :development, :test do
gem 'rspec-rails'
......@@ -144,6 +113,11 @@ after_bundle do
copy_file 'src/config/puma.rb', 'config/puma.rb'
remove_file 'config/database.yml'
copy_file 'src/config/database.yml', 'config/database.yml'
remove_file 'config/storage.yml'
copy_file 'src/config/storage.yml', 'config/storage.yml'
gsub_file 'config/environments/production.rb', 'config.active_storage.service = :local', 'config.active_storage.service = :s3'
copy_file 'src/config/ohm.rb', 'config/initializers/ohm.rb'
remove_file 'config/initializers/cors.rb'
copy_file 'src/config/cors.rb', 'config/initializers/cors.rb'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment