Commit 39ac559e authored by pei-chi.huang's avatar pei-chi.huang
Browse files

fix for server deployment

parent c43f66eb
......@@ -3,7 +3,7 @@ require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
require 'capistrano/delayed_job'
#require 'capistrano/delayed_job'
# Include tasks from other gems included in your Gemfile
#
......@@ -17,13 +17,15 @@ require 'capistrano/delayed_job'
# https://github.com/capistrano/passenger
#
require 'capistrano/rvm'
# require 'capistrano/rbenv'
require 'capistrano/nvm' # Node version manager
require 'capistrano/npm' # Node package manager
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/rails/assets'
# require 'capistrano/passenger'
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
Rake::Task[:production].invoke
# Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
#Rake::Task[:production].invoke
......@@ -24,7 +24,7 @@ gem 'bootstrap-sass', '~>3.3.6'
#gem 'sqlite3'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.0'
#gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
......@@ -34,6 +34,9 @@ gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'rack-mini-profiler', git: 'https://github.com/MiniProfiler/rack-mini-profiler'
gem 'dotenv-rails', require: 'dotenv/rails-now'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
......@@ -62,11 +65,13 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem "capistrano", "~> 3.6"
gem 'capistrano3-delayed-job'
gem 'capistrano-rvm'
gem 'capistrano', '3.9.1'
gem 'capistrano-bundler'
gem 'capistrano-npm'
gem 'capistrano-nvm', require: false
gem 'capistrano-rails'
gem 'capistrano-rvm'
# gem 'capistrano3-delayed-job'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
......
GIT
remote: https://github.com/MiniProfiler/rack-mini-profiler
revision: 39e78748ea0dce5ff767042089b9cfd733aa136e
specs:
rack-mini-profiler (1.1.3)
rack (>= 1.2.0)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.0)
actionpack (= 5.0.0)
nio4r (~> 1.2)
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0)
actionpack (= 5.0.0)
actionview (= 5.0.0)
activejob (= 5.0.0)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.0)
actionview (= 5.0.0)
activesupport (= 5.0.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.0)
activesupport (= 5.0.0)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (5.0.0)
activesupport (= 5.0.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
globalid (>= 0.3.6)
activemodel (5.0.0)
activesupport (= 5.0.0)
activerecord (5.0.0)
activemodel (= 5.0.0)
activesupport (= 5.0.0)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activesupport (5.0.0)
activesupport (5.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
airbrussh (1.1.1)
airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (7.0.0)
autoprefixer-rails (6.3.7)
arel (7.1.4)
autoprefixer-rails (9.7.2)
execjs
bcrypt (3.1.11)
bootstrap-sass (3.3.6)
bcrypt (3.1.13)
bindex (0.8.1)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
bootstrap-will_paginate (0.0.10)
bootstrap-will_paginate (0.0.11)
will_paginate
builder (3.2.2)
byebug (9.0.5)
capistrano (3.6.1)
builder (3.2.3)
byebug (11.0.1)
capistrano (3.9.1)
airbrussh (>= 1.0.0)
capistrano-harrow
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (1.2.0)
capistrano-bundler (1.6.0)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-harrow (0.5.3)
capistrano-rails (1.2.0)
capistrano-npm (1.0.3)
capistrano (>= 3.0.0)
capistrano-nvm (0.0.7)
capistrano (~> 3.1)
capistrano-rails (1.4.0)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano3-delayed-job (1.7.2)
capistrano (~> 3.0, >= 3.0.0)
cocoon (1.2.9)
coffee-rails (4.2.1)
cocoon (1.2.14)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.2.x)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
daemons (1.2.4)
debug_inspector (0.0.2)
delayed_job (4.1.2)
activesupport (>= 3.0, < 5.1)
delayed_job_active_record (4.1.1)
activerecord (>= 3.0, < 5.1)
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
crass (1.0.5)
daemons (1.3.1)
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
activerecord (>= 3.0, < 6.1)
delayed_job (>= 3.0, < 5)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
erubis (2.7.0)
execjs (2.7.0)
ffi (1.9.14)
font-awesome-rails (4.6.3.1)
railties (>= 3.2, < 5.1)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.5.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.2.1)
ffi (1.11.2)
font-awesome-rails (4.7.0.5)
railties (>= 3.2, < 6.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.7.0)
concurrent-ruby (~> 1.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
......@@ -105,114 +116,116 @@ GEM
turbolinks
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
json (2.0.2)
kgio (2.10.0)
json (2.2.0)
kgio (2.11.2)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
loofah (2.3.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.2.0)
nio4r (1.2.1)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
pdf-core (0.6.1)
pg (0.18.4)
prawn (2.1.0)
pdf-core (~> 0.6.1)
ttfunk (~> 1.4.0)
prawn-table (0.1.2)
puma (3.4.0)
rack (2.0.1)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.13.0)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0)
nio4r (2.5.2)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
pdf-core (0.7.0)
pg (1.1.4)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
rack (2.0.7)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.0)
actioncable (= 5.0.0)
actionmailer (= 5.0.0)
actionpack (= 5.0.0)
actionview (= 5.0.0)
activejob (= 5.0.0)
activemodel (= 5.0.0)
activerecord (= 5.0.0)
activesupport (= 5.0.0)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.0)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.0)
actionpack (= 5.0.0)
activesupport (= 5.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.17.0)
rake (12.0.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rubyzip (1.2.0)
sablon (0.0.20)
nokogiri (>= 1.6.0)
rubyzip (>= 1.1)
sass (3.4.22)
sass-rails (5.0.5)
raindrops (0.19.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
rubyzip (2.0.0)
sablon (0.3.2)
nokogiri (>= 1.8.5)
rubyzip (>= 1.1.1)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
spring (1.7.2)
spring-watcher-listen (2.0.0)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (~> 1.2)
sprockets (3.6.3)
spring (>= 1.2, < 3.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.1.1)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sshkit (1.11.4)
sshkit (1.20.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
ttfunk (1.4.0)
turbolinks (5.0.0)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.10)
ttfunk (1.5.1)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (3.0.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicorn (5.1.0)
unicorn (5.5.1)
kgio (~> 2.6)
raindrops (~> 0.7)
web-console (3.3.1)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
debug_inspector
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.4)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.1.0)
websocket-extensions (0.1.4)
will_paginate (3.1.8)
PLATFORMS
ruby
......@@ -222,14 +235,17 @@ DEPENDENCIES
bootstrap-sass (~> 3.3.6)
bootstrap-will_paginate (~> 0.0.10)
byebug
capistrano (~> 3.6)
capistrano (= 3.9.1)
capistrano-bundler
capistrano-npm
capistrano-nvm
capistrano-rails
capistrano-rvm
capistrano3-delayed-job
cocoon
coffee-rails (~> 4.2)
daemons
delayed_job_active_record
dotenv-rails
font-awesome-rails
jbuilder (~> 2.5)
jquery-rails
......@@ -241,7 +257,7 @@ DEPENDENCIES
pg
prawn
prawn-table
puma (~> 3.0)
rack-mini-profiler!
rails (~> 5.0.0)
sablon
sass-rails (~> 5.0)
......@@ -255,4 +271,4 @@ DEPENDENCIES
will_paginate (~> 3.1.0)
BUNDLED WITH
1.12.5
1.17.3
require_relative 'boot'
require 'rails/all'# Require the gems listed in Gemfile, including any gems
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require 'dotenv'
Dotenv.load
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
Bundler.require(*Rails.groups,:plugins)
module MolApp
class Application < Rails::Application
config.active_job.queue_adapter = :delayed_job
#config.active_job.queue_adapter = :delayed_job
config.time_zone="Berlin"
config.before_configuration do
YAML.load(File.read(File.join(Rails.root,'config',"env.yml"))).each do |var,value|
ENV[var]=value
end
# YAML.load(File.read(File.join(Rails.root,'config',"env.yml"))).each do |var,value|
# ENV[var]=value
# end
end
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
......
api_key: 'key-d977f6da2e29f864240f769958f16017'
domain: 'sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org'
username: 'postmaster@sandboxa4c11f13bfcb46bb8ba971d74fb255cc.mailgun.org'
password: '7a7d729689e994c6f24cb8744f0e11fa'
# gmail_username: 'username@gmail.com'
# gmail_password: 'gmail password'
......@@ -2,7 +2,7 @@
development:
adapter: postgresql
encoding: unicode
database: mol_app_dev
database: ela
pool: 5
username: ela
password: ela
......@@ -11,7 +11,7 @@ development:
test:
adapter: postgresql
encoding: unicode
database: mol_app_test
database: ela
pool: 5
username: ela
password: ela
......@@ -20,7 +20,7 @@ test:
production:
adapter: postgresql
encoding: unicode
database: mol_app_dev
database: ela
pool: 5
username: ela
password: ela
......
# config valid only for current version of Capistrano
lock '3.6.1'
lock '3.9.1'
set :application, 'ela2'
set :application, 'ela'
set :repo_url, 'git@git.scc.kit.edu:ComPlat/ela2.git'
# Default branch is :master
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app_name
# set :deploy_to, '/var/www/my_app_name'
set :deploy_to, '/home/deploy/www/ela'
# Default value for :scm is :git
# set :scm, :git
set :rails_env, "production"
set :unicorn_env, "production"
set :unicorn_rack_env, "production"
# Default value for :format is :airbrussh.
# set :format, :airbrussh
set :nvm_type, :user
set :nvm_node, File.exist?('.nvmrc') && File.read('.nvmrc').strip || 'v10.15.3'
set :npm_version, File.exist?('.npm-version') && File.read('.npm-version').strip || '6.10.1'
set :nvm_map_bins, fetch(:nvm_map_bins, []).push('rake')
set :nvm_map_bins, fetch(:nvm_map_bins, []).push('bundle')
# Default value for :format is :pretty
# set :format, :pretty
# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto
# Default value for :log_level is :debug
# set :log_level, :debug
set :format_options, command_output: true
set :log_file, 'log/capistrano.log'
# Default value for :pty is false
# set :pty, true
set :stage, :production
set :branch, 'mailer'
set :deploy_to, '/home/ela/www/ela'
#role :all, %w{deploy@server.com}
server 'itg-complat1-l.itg.kit.edu', user: 'ela', roles: %w{web app db}, my_property: :my_value
fetch(:default_env).merge!(rails_env: :production)
# Default value for :linked_files is []
append :linked_files, 'config/database.yml', 'config/secrets.yml', 'config/env.yml'
set :linked_files, fetch(:linked_files, []).push(
'config/database.yml',
'config/secrets.yml',
'.env'
)
# Default value for linked_dirs is []
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system'
set :linked_dirs, fetch(:linked_dirs, []).push(
'node_modules',
'log',
'tmp/pids', 'tmp/cache', 'tmp/sockets'
)
version = File.readlines('.ruby-version')[0].strip if File.exist?('.ruby-version')
gemset = File.readlines('.ruby-gemset')[0].strip if File.exist?('.ruby-gemset')
set(:rvm_ruby_version, "#{version}#{'@' if gemset}#{gemset}") if File.exist?('.ruby-version')
set :slackistrano, false
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
set :keep_releases, 5
# set :keep_releases, 5
# before 'deploy:migrate', 'deploy:backup'
## NMV and NPM tasks
## Install node version if not installed
before 'nvm:validate', 'deploy:nvm_check'
## Install defined version of npm if not selected
before 'nvm:validate', 'deploy:npm_install_npm'
## Clear all npm packages
before 'npm:install', 'deploy:clear_node_module'
after 'deploy:publishing', 'deploy:restart'
namespace :git do
task :update_repo_url do
on roles(:all) do
within repo_path do
execute :git, 'remote', 'set-url', 'origin', fetch(:repo_url)
end
end
end
end
namespace :deploy do
task :nvm_check do
on roles :app do
execute <<~SH
source "#{fetch(:nvm_path)}/nvm.sh" && [[ $(nvm version #{fetch(:nvm_node)}) != "#{fetch(:nvm_node)}" ]] && nvm install #{fetch(:nvm_node)}; nvm use #{fetch(:nvm_node)}
SH
end
end
task :npm_install_npm do
on roles :app do
execute <<~SH
source "#{fetch(:nvm_path)}/nvm.sh" && nvm use #{fetch(:nvm_node)} && [[ $(npm -v npm) == "#{fetch(:npm_version)}" ]] && echo "npm already installed" || npm install -g npm
SH
# source "#{fetch(:nvm_path)}/nvm.sh" && nvm use #{fetch(:nvm_node)} && [[ $(npm -v npm) == $(cat .npm-version) ]] && echo "npm already installed" || npm install -g npm