Skip to content

Instantly share code, notes, and snippets.

@iamdbc
Last active August 9, 2017 02:13
Show Gist options
  • Save iamdbc/33babb7b307c429d723b315b45c5545c to your computer and use it in GitHub Desktop.
Save iamdbc/33babb7b307c429d723b315b45c5545c to your computer and use it in GitHub Desktop.
mina 1.x config file
require 'mina/rails'
require 'mina/git'
require 'mina/rvm' # for rvm support. (https://rvm.io)
require 'mina/puma'
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# 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 :domain, 'ssh_server'
set :deploy_to, '/data/wwwroot/domain.com'
set :repository, 'git@github.com:project.git'
set :branch, 'master'
set :port, '9876'
# 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.
# shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/pids', 'tmp/sockets', 'public/uploads')
set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml', 'config/puma.rb', 'config/app.yml')
# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
task :environment do
# For those using RVM, use this to load an RVM version@gemset.
invoke :'rvm:use', 'ruby-2.3.3@default'
end
# Put any custom commands you need to run at setup
# All paths in `shared_dirs` and `shared_paths` will be created on their own.
task :setup do
command %[touch "#{fetch(:shared_path)}/config/database.yml"]
command %[touch "#{fetch(:shared_path)}/config/secrets.yml"]
command %[touch "#{fetch(:shared_path)}/config/puma.rb"]
command %[touch "#{fetch(:shared_path)}/config/app.yml"]
command %[chgrp -R www "#{fetch(:deploy_to)}"]
command %[chmod -R 755 "#{fetch(:deploy_to)}"]
comment "Be sure to edit '#{fetch(:shared_path)}/config/database.yml', 'secrets.yml' and puma.rb."
end
desc "Deploys the current version to the server."
task :deploy do
# uncomment this line to make sure you pushed your local branch to the remote origin
# invoke :'git:ensure_pushed'
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
on :launch do
in_path(fetch(:current_path)) do
command %{mkdir -p tmp/}
command %{touch tmp/restart.txt}
# for first deploy
# invoke :'puma:start'
invoke :'puma:phased_restart'
end
end
end
end
# useage: mina puma:restart
desc "Manage puma"
namespace :puma do
task :status do
invoke :'puma:status'
end
task :restart do
invoke :'puma:restart'
end
task :start do
invoke :'puma:start'
end
task :stop do
invoke :'puma:stop'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment