webflow_cap 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1062fc6521705bc2b35a6e214298e3b0e8959486
4
- data.tar.gz: ab642147c90f33cf298ad78c46d7679a455f5a18
3
+ metadata.gz: 67006ecdc85663bc7c411b169bf8671e5093dcba
4
+ data.tar.gz: 949091f4bfc3435466bc1921e611f7d944a9375b
5
5
  SHA512:
6
- metadata.gz: b09d5888b9644935e0eb5affe27190a2806698d0781968770284cf7d1486c8824e4807ba95bad7f0b9565c23d7341f7ff79059c85509dd680bd7dce346fcfce8
7
- data.tar.gz: 7a1be336446d4fb479990191bb67c4468f97b1b458a325f49f575f133df33d33aa56e2f03aa3b7222dda148a37a71c7e5ea92d320b4b1a9fd0fa005a9f4cd15c
6
+ metadata.gz: 9f06ec46fc1b5bcfa901fd80d41542173de2a03d57ad3fdd699c727e35ce0aadd984de729640882b75f93dfbf64116316cb1fce09908b87287e2bf82d129528e
7
+ data.tar.gz: 90d1dae73cab2a66268522681a9e2dae3811900eee518f33b09e9aec9e5cac78f2e1c764da72c8b3af199361738a68104740e80474edcc64ef30312e5015f0be
@@ -4,6 +4,7 @@ namespace :load do
4
4
  set :application_server, fetch(:application_server, "puma")
5
5
  set :branch, fetch(:branch, "master")
6
6
  set :scm, fetch(:scm, :git)
7
+ set :ruby_version, fetch(:ruby_version, "2.1")
7
8
 
8
9
  # variables without default values
9
10
  set :deploy_via, :remote_cache
@@ -14,21 +15,33 @@ namespace :load do
14
15
  set :deploy_to, -> { "/docs/#{fetch :user}/#{fetch :domain}/#{fetch :application}" }
15
16
  set :server_port, -> { 10000 + ((fetch :user)[3..6] + "0").to_i }
16
17
 
17
- set :default_env, {
18
- 'PATH' => "PATH=/docs/#{fetch :user}/.gem/ruby/2.1.5/bin:/opt/ruby/2.1.5/bin:$PATH"
18
+ set :default_env, -> {
19
+ {'PATH' => "/docs/#{fetch :user}/.gem/ruby/#{fetch :ruby_version}/bin:/opt/ruby/#{fetch :ruby_version}/bin:$PATH"}
19
20
  }
21
+
22
+ set :runit_service_dir, -> {"#{fetch :home}/etc/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"}
20
23
  end
21
24
  end
22
25
 
23
26
  namespace :runit do
24
27
  task :setup_application_server do
25
28
  on roles :all do
29
+ daemon_name = "rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
30
+ runit_dir = "#{fetch :home}/etc/sv/#{daemon_name}"
31
+
32
+ if test("[ -e #{runit_dir} ]")
33
+ info("runit ready @ #{runit_dir}")
34
+ next
35
+ end
36
+
26
37
  daemon_script = <<-EOF
27
38
  #!/bin/bash -e
39
+ exec 2>&1
28
40
  export HOME=#{fetch :home}
41
+ export PATH=#{fetch(:default_env)['PATH']}
29
42
  source $HOME/.bashrc
30
43
  cd #{fetch :deploy_to}/current
31
- exec bundle exec #{fetch :application_server} start -p #{fetch :server_port} -e production -d 2>&1
44
+ exec bundle exec #{fetch :application_server} -p #{fetch :server_port} -e production 2>&1
32
45
  EOF
33
46
 
34
47
  log_script = <<-EOF
@@ -36,13 +49,13 @@ exec bundle exec #{fetch :application_server} start -p #{fetch :server_port} -e
36
49
  exec svlogd -tt ./main
37
50
  EOF
38
51
 
39
- execute "mkdir -p #{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
40
- execute "mkdir -p #{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}/log/main"
41
- upload! StringIO.new(daemon_script), "#{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}/run"
42
- upload! StringIO.new(log_script), "#{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}/log/run"
43
- execute "chmod +x #{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}/run"
44
- execute "chmod +x #{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}/log/run"
45
- execute "ln -nfs #{fetch :home}/etc/sv/run-rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application} ~/etc/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
52
+ execute "mkdir -p #{runit_dir}"
53
+ execute "mkdir -p #{runit_dir}/log/main"
54
+ upload! StringIO.new(daemon_script), "#{runit_dir}/run"
55
+ upload! StringIO.new(log_script), "#{runit_dir}/log/run"
56
+ execute "chmod +x #{runit_dir}/run"
57
+ execute "chmod +x #{runit_dir}/log/run"
58
+ execute "ln -nfs #{runit_dir} #{fetch :runit_service_dir}"
46
59
  end
47
60
  end
48
61
 
@@ -53,7 +66,7 @@ namespace :htaccess do
53
66
  task :create do
54
67
  on roles :all do
55
68
  if test("[ -e #{shared_path}/.htaccess ]")
56
- warn "[skip] .htaccess already exists"
69
+ info "[skip] .htaccess already exists"
57
70
  elsif fetch(:password_protected)
58
71
  ask(:htaccess_user, fetch(:user))
59
72
  ask(:htaccess_pass, nil)
@@ -72,7 +85,7 @@ Require valid-user
72
85
 
73
86
  task :remove do
74
87
  on roles :all do
75
- if ("[ -e #{shared_path}/.htaccess ]")
88
+ if test("[ -e #{shared_path}/.htaccess ]")
76
89
  execute "rm -f #{shared_path}/.htaccess"
77
90
  execute "rm -f #{shared_path}/.htpasswd"
78
91
  execute "rm -f #{current_path}/.htaccess"
@@ -86,11 +99,17 @@ end
86
99
  namespace :apache do
87
100
  task :setup_reverse_proxy do
88
101
  on roles :all do
102
+ path = "#{fetch :home}/#{fetch :domain}/htdocs"
103
+
104
+ if test("[ -e #{path} ]")
105
+ info "reverse proxy configured @ #{path}/.htaccess"
106
+ next
107
+ end
108
+
89
109
  htaccess = <<-EOF
90
110
  RewriteEngine On
91
111
  RewriteRule ^(.*)$ http://localhost:#{fetch :server_port}/$1 [P]
92
112
  EOF
93
- path = "#{fetch :home}/#{fetch :domain}"
94
113
  execute "mkdir -p #{path}"
95
114
  upload! StringIO.new(htaccess), "#{path}/.htaccess"
96
115
  execute "chmod +r #{path}/.htaccess"
@@ -103,17 +122,23 @@ end
103
122
  namespace :deploy do
104
123
  task :start do
105
124
  on roles :all do
106
- execute "sv start #{fetch :home}/etc/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
125
+ execute "sv start #{fetch :runit_service_dir}"
107
126
  end
108
127
  end
109
128
  task :stop do
110
129
  on roles :all do
111
- execute "sv stop #{fetch :home}/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
130
+ execute "sv stop #{fetch :runit_service_dir}"
112
131
  end
113
132
  end
114
133
  task :restart do
115
134
  on roles :all do
116
- execute "sv restart #{fetch :home}/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
135
+ execute "sv restart #{fetch :runit_service_dir}"
136
+ end
137
+ end
138
+
139
+ task :status do
140
+ on roles :all do
141
+ execute "sv status #{fetch :runit_service_dir}"
117
142
  end
118
143
  end
119
144
 
@@ -24,8 +24,8 @@ namespace :mysql do
24
24
  execute "mysql -e 'CREATE DATABASE IF NOT EXISTS #{config[env]['database']} CHARACTER SET utf8 COLLATE utf8_general_ci;'"
25
25
  end
26
26
 
27
- execute "mkdir -p #{:shared_path}/config"
28
- upload! StringIO.new(config.to_yaml), "#{:shared_path}/config/database.yml"
27
+ execute "mkdir -p #{shared_path}/config"
28
+ upload! StringIO.new(config.to_yaml), "#{shared_path}/config/database.yml"
29
29
  end
30
30
  end
31
31
 
@@ -0,0 +1,2 @@
1
+ load File.expand_path("../tasks/base.rake", __FILE__)
2
+ load File.expand_path("../tasks/mysql.rake", __FILE__)
data/webflow_cap.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
14
  gem.name = "webflow_cap"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = "0.0.2"
16
+ gem.version = "0.0.4"
17
17
 
18
18
  # dependencies
19
19
  gem.add_dependency 'capistrano', '~>3.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webflow_cap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Aman
@@ -37,7 +37,7 @@ files:
37
37
  - Rakefile
38
38
  - lib/capistrano/tasks/base.rake
39
39
  - lib/capistrano/tasks/mysql.rake
40
- - lib/webflow_cap.rb
40
+ - lib/capistrano/webflow.rb
41
41
  - webflow_cap.gemspec
42
42
  homepage: https://rubygems.org/gems/webflow_cap
43
43
  licenses:
data/lib/webflow_cap.rb DELETED
@@ -1,2 +0,0 @@
1
- load File.expand_path("../capistrano/tasks/base.rake", __FILE__)
2
- load File.expand_path("../capistrano/tasks/mysql.rake", __FILE__)