webflow_cap 0.1.0 → 0.2.3
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 +4 -4
- data/README.md +26 -1
- data/bin/webflow_capify +14 -0
- data/lib/capistrano/tasks/base.rake +6 -2
- data/lib/capistrano/tasks/rails.rake +8 -4
- data/lib/capistrano/tasks/webflow_install.rake +67 -0
- data/lib/capistrano/templates/deploy.rb.erb +5 -1
- data/lib/capistrano/templates/stage.rb.erb +3 -1
- data/lib/capistrano/webflow/base.rb +0 -1
- data/lib/capistrano/webflow/install.rb +1 -0
- data/webflow_cap.gemspec +2 -3
- metadata +11 -22
- data/lib/capistrano/tasks/webflow.rake +0 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74f2868530b5363dab7ed43334cce69098d502af
|
4
|
+
data.tar.gz: e122a0647df6f6aa6fe009fb8eb8d930595529f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b50e2682615ac7da485e18743865a2818c12a5f24ba7565ecb077043ef5b117ba1df84b29f88740348a08c2fba609435bbffbab4dee811bbe0883d6829822f9
|
7
|
+
data.tar.gz: 624812568eea5011dab37f02ecc5c08dae00a80d15326a4ce012ae1edfdf9447efb0997415083cbe6549361c94615be8e3f5876b1cd869bac419e859a9f096ea
|
data/README.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# webflow_cap
|
2
|
-
|
2
|
+
|
3
|
+
This gem is a plugin for [capistrano 3](http://capistranorb.com/) to make deployment of rails applications to [.webflow](http://www.webflow.de) servers easy.
|
4
|
+
|
5
|
+
Applications that get deployed with the capistrano tasks are automatically configured and setup to run supervised.
|
6
|
+
The database.yml is automatically created and configured to use the right connection settings.
|
7
|
+
An application specific database will also be created.
|
8
|
+
|
9
|
+
The application server (which defaults to [passenger standalone](https://www.phusionpassenger.com/#about)) will be started and supervised by [runit](http://smarden.org/runit/).
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
1. Add the following lines to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'passenger'
|
17
|
+
|
18
|
+
group :development do
|
19
|
+
gem 'capistrano-rails', group: :development
|
20
|
+
gem 'webflow_cap'
|
21
|
+
end
|
22
|
+
```
|
23
|
+
2. Execute `bundle install` to install these gems.
|
24
|
+
3. Execute `bundle exec webflow_capify` which asks you some questions and installs capistrano templates with sane defaults to your project.
|
25
|
+
|
26
|
+
With these capistrano files in place all you need to do is execute `bundle exec cap production deploy` to spin up your rails application.
|
27
|
+
|
3
28
|
## License
|
4
29
|
|
5
30
|
MIT; Copyright (c) 2014 Florian Aman, webflow GmbH
|
data/bin/webflow_capify
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
require 'capistrano/all'
|
3
|
+
|
4
|
+
stages = "production"
|
5
|
+
set :stage, :production
|
6
|
+
role :app, %w{}
|
7
|
+
|
8
|
+
require 'capistrano/setup'
|
9
|
+
require 'capistrano/deploy'
|
10
|
+
require 'capistrano/webflow/install'
|
11
|
+
|
12
|
+
Dir.glob('capistrano/tasks/*.rake').each { |r| import r }
|
13
|
+
|
14
|
+
Capistrano::Application.invoke("webflow:install")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
namespace :load do
|
2
2
|
task :defaults do
|
3
3
|
# variables with default values
|
4
|
-
set :application_server, fetch(:application_server, "
|
4
|
+
set :application_server, fetch(:application_server, "passenger")
|
5
5
|
set :branch, fetch(:branch, "master")
|
6
6
|
set :scm, fetch(:scm, :git)
|
7
7
|
set :ruby_version, fetch(:ruby_version, "2.1")
|
@@ -13,7 +13,7 @@ namespace :load do
|
|
13
13
|
|
14
14
|
set :home, -> { "/docs/#{fetch :user}" }
|
15
15
|
set :deploy_to, -> { "/docs/#{fetch :user}/#{fetch :domain}/#{fetch :application}" }
|
16
|
-
set :server_port, -> { 10000 + ((fetch :user)[
|
16
|
+
set :server_port, -> { 10000 + ((fetch :user)[4..6] + "0").to_i }
|
17
17
|
|
18
18
|
set :linked_files, %w{}
|
19
19
|
|
@@ -24,22 +24,26 @@ namespace :load do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
namespace :deploy do
|
27
|
+
desc 'Start application'
|
27
28
|
task :start do
|
28
29
|
on roles :all do
|
29
30
|
execute "sv start #{fetch :runit_service_dir}"
|
30
31
|
end
|
31
32
|
end
|
33
|
+
desc 'Stop application'
|
32
34
|
task :stop do
|
33
35
|
on roles :all do
|
34
36
|
execute "sv stop #{fetch :runit_service_dir}"
|
35
37
|
end
|
36
38
|
end
|
39
|
+
desc 'Restart application'
|
37
40
|
task :restart do
|
38
41
|
on roles :all do
|
39
42
|
execute "sv restart #{fetch :runit_service_dir}"
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
46
|
+
desc 'Show supervision status for application'
|
43
47
|
task :status do
|
44
48
|
on roles :all do
|
45
49
|
execute "sv status #{fetch :runit_service_dir}"
|
@@ -1,11 +1,12 @@
|
|
1
1
|
namespace :load do
|
2
2
|
task :defaults do
|
3
|
-
set :runit_service_dir, -> {"#{fetch :home}/etc/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"}
|
3
|
+
set :runit_service_dir, -> {"#{fetch :home}/etc/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}-#{fetch :stage}"}
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
7
|
namespace :rails do
|
8
|
-
|
8
|
+
desc 'Show possible ruby versions on configured .webflow server'
|
9
|
+
task :ruby_versions do
|
9
10
|
on roles :all do
|
10
11
|
within '/opt/ruby' do
|
11
12
|
execute(:ls)
|
@@ -35,7 +36,7 @@ RewriteRule ^(.*)$ http://localhost:#{fetch :server_port}/$1 [P]
|
|
35
36
|
|
36
37
|
task :setup_application_server do
|
37
38
|
on roles :all do
|
38
|
-
daemon_name = "rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
|
39
|
+
daemon_name = "rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}-#{fetch :stage}"
|
39
40
|
runit_dir = "#{fetch :home}/etc/sv/#{daemon_name}"
|
40
41
|
|
41
42
|
if test("[ -e #{runit_dir} ]")
|
@@ -43,6 +44,9 @@ RewriteRule ^(.*)$ http://localhost:#{fetch :server_port}/$1 [P]
|
|
43
44
|
next
|
44
45
|
end
|
45
46
|
|
47
|
+
application_server = fetch(:application_server)
|
48
|
+
application_server + ' start' if application_server == 'passenger'
|
49
|
+
|
46
50
|
daemon_script = <<-EOF
|
47
51
|
#!/bin/bash -e
|
48
52
|
exec 2>&1
|
@@ -51,7 +55,7 @@ export PATH=#{fetch(:default_env)['PATH']}
|
|
51
55
|
source $HOME/.bashrc
|
52
56
|
source $HOME/#{fetch :domain}/etc/rubyrc
|
53
57
|
cd #{fetch :deploy_to}/current
|
54
|
-
exec bundle exec #{
|
58
|
+
exec bundle exec #{application_server} -p #{fetch :server_port} -e #{fetch :stage} 2>&1
|
55
59
|
EOF
|
56
60
|
|
57
61
|
log_script = <<-EOF
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'pathname'
|
3
|
+
require 'capistrano/configuration/question.rb'
|
4
|
+
|
5
|
+
namespace :webflow do
|
6
|
+
desc "Install webflow flavoured capistrano files"
|
7
|
+
task :install do
|
8
|
+
question = Capistrano::Configuration::Question
|
9
|
+
|
10
|
+
repository_url = if File.exists?(Dir.getwd + '/.git')
|
11
|
+
`git config --get remote.origin.url`.strip
|
12
|
+
end
|
13
|
+
|
14
|
+
set :application, ask("Application name", File.basename(Dir.getwd))
|
15
|
+
set :ruby_version, ask("Ruby version", "2.1.5")
|
16
|
+
set :repo_url, ask("Repository URL", repository_url)
|
17
|
+
set :user, ask("Username", "f909999")
|
18
|
+
set :domain, ask("Domain", "example.com")
|
19
|
+
set :server, -> { ask("Server", fetch(:domain)) }
|
20
|
+
set :server_port, -> { 10000 + ((fetch :user)[4..6] + "0").to_i }
|
21
|
+
|
22
|
+
@application = fetch(:application)
|
23
|
+
@ruby_version = fetch(:ruby_version)
|
24
|
+
@repo_url = fetch(:repo_url)
|
25
|
+
@user = fetch(:user)
|
26
|
+
@domain = fetch(:domain)
|
27
|
+
@server = fetch(:server)
|
28
|
+
@server_port = fetch(:server_port)
|
29
|
+
|
30
|
+
envs = ENV['STAGES'] || 'staging,production'
|
31
|
+
|
32
|
+
tasks_dir = Pathname.new('lib/capistrano/tasks')
|
33
|
+
config_dir = Pathname.new('config')
|
34
|
+
deploy_dir = config_dir.join('deploy')
|
35
|
+
|
36
|
+
deploy_rb = File.expand_path("../../templates/deploy.rb.erb", __FILE__)
|
37
|
+
stage_rb = File.expand_path("../../templates/stage.rb.erb", __FILE__)
|
38
|
+
capfile = File.expand_path("../../templates/Capfile", __FILE__)
|
39
|
+
|
40
|
+
FileUtils.mkdir_p deploy_dir
|
41
|
+
|
42
|
+
entries = [{template: deploy_rb, file: config_dir.join('deploy.rb')}]
|
43
|
+
entries += envs.split(',').map { |stage| {template: stage_rb, file: deploy_dir.join("#{stage}.rb")} }
|
44
|
+
|
45
|
+
entries.each do |entry|
|
46
|
+
if File.exists?(entry[:file]) && question.new("Overwrite #{entry[:file]}?", 'y').call != 'y'
|
47
|
+
warn "[skip] #{entry[:file]} already exists"
|
48
|
+
else
|
49
|
+
File.open(entry[:file], 'w+') do |f|
|
50
|
+
f.write(ERB.new(File.read(entry[:template])).result(binding))
|
51
|
+
puts "create #{entry[:file]}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
FileUtils.mkdir_p tasks_dir
|
57
|
+
|
58
|
+
if File.exists?('Capfile') && question.new("Overwrite Capfile?", 'y').call != 'y'
|
59
|
+
warn "[skip] Capfile already exists"
|
60
|
+
else
|
61
|
+
FileUtils.cp(capfile, 'Capfile')
|
62
|
+
puts 'create Capfile'
|
63
|
+
end
|
64
|
+
|
65
|
+
puts 'Capified'
|
66
|
+
end
|
67
|
+
end
|
@@ -8,4 +8,8 @@ set :application, "<%= @application %>"
|
|
8
8
|
set :repo_url, "<%= @repo_url %>"
|
9
9
|
|
10
10
|
# use ruby_version to set a specific ruby version
|
11
|
-
# set :ruby_version, "<%= @ruby_version %>"
|
11
|
+
# set :ruby_version, "<%= @ruby_version %>"
|
12
|
+
|
13
|
+
#set :application_server, "passenger"
|
14
|
+
|
15
|
+
#set :linked_files, %w{}
|
@@ -8,4 +8,6 @@ set :domain, "<%= @domain %>"
|
|
8
8
|
# set :password_protected, true
|
9
9
|
|
10
10
|
# set the servername to the servername or ipaddress from webflow e.g. server.example.com or 192.168.0.1
|
11
|
-
server "<%= @server %>", user: fetch(:user), roles: %w(:web :app :db), primary: true
|
11
|
+
server "<%= @server %>", user: fetch(:user), roles: %w(:web :app :db), primary: true
|
12
|
+
|
13
|
+
#set :server_port, <%= @server_port %> # please only change after you talk to webflow staff
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../../tasks/webflow_install.rake", __FILE__)
|
data/webflow_cap.gemspec
CHANGED
@@ -13,10 +13,9 @@ 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.
|
16
|
+
gem.version = "0.2.3"
|
17
17
|
|
18
18
|
# dependencies
|
19
19
|
gem.add_dependency 'capistrano', '~>3.2'
|
20
|
-
gem.add_dependency 'capistrano-
|
21
|
-
gem.add_dependency 'capistrano-bundler'
|
20
|
+
gem.add_dependency 'capistrano-bundler', '~>1.1'
|
22
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webflow_cap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Aman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -24,38 +24,25 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: capistrano-rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: capistrano-bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - "
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '1.1'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '1.1'
|
55
41
|
description: Deploy Rails apps
|
56
42
|
email:
|
57
43
|
- fa@webflow.de
|
58
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- webflow_capify
|
59
46
|
extensions: []
|
60
47
|
extra_rdoc_files: []
|
61
48
|
files:
|
@@ -63,16 +50,18 @@ files:
|
|
63
50
|
- LICENSE
|
64
51
|
- README.md
|
65
52
|
- Rakefile
|
53
|
+
- bin/webflow_capify
|
66
54
|
- lib/capistrano/tasks/base.rake
|
67
55
|
- lib/capistrano/tasks/htaccess.rake
|
68
56
|
- lib/capistrano/tasks/mysql.rake
|
69
57
|
- lib/capistrano/tasks/rails.rake
|
70
|
-
- lib/capistrano/tasks/
|
58
|
+
- lib/capistrano/tasks/webflow_install.rake
|
71
59
|
- lib/capistrano/templates/Capfile
|
72
60
|
- lib/capistrano/templates/deploy.rb.erb
|
73
61
|
- lib/capistrano/templates/stage.rb.erb
|
74
62
|
- lib/capistrano/webflow/base.rb
|
75
63
|
- lib/capistrano/webflow/htaccess.rb
|
64
|
+
- lib/capistrano/webflow/install.rb
|
76
65
|
- lib/capistrano/webflow/mysql.rb
|
77
66
|
- lib/capistrano/webflow/rails.rb
|
78
67
|
- lib/webflow_cap.rb
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
namespace :webflow do
|
5
|
-
desc "Install webflow flavoured capistrano files"
|
6
|
-
task :install do
|
7
|
-
on roles :all do
|
8
|
-
set :application, ask("Application name", "APP")
|
9
|
-
set :ruby_version, ask("Ruby version", "2.1.5")
|
10
|
-
set :repo_url, ask("Repository URL", nil)
|
11
|
-
set :user, ask("Username", "f999999")
|
12
|
-
set :domain, ask("Domain", "example.com")
|
13
|
-
set :server, ask("Server", "server.example.com")
|
14
|
-
|
15
|
-
@application = fetch(:application)
|
16
|
-
@ruby_version = fetch(:ruby_version)
|
17
|
-
@repo_url = fetch(:repo_url)
|
18
|
-
@user = fetch(:user)
|
19
|
-
@domain = fetch(:domain)
|
20
|
-
@server = fetch(:server)
|
21
|
-
|
22
|
-
envs = ENV['STAGES'] || 'staging,production'
|
23
|
-
|
24
|
-
tasks_dir = Pathname.new('lib/capistrano/tasks')
|
25
|
-
config_dir = Pathname.new('config')
|
26
|
-
deploy_dir = config_dir.join('deploy')
|
27
|
-
|
28
|
-
deploy_rb = File.expand_path("../../templates/deploy.rb.erb", __FILE__)
|
29
|
-
stage_rb = File.expand_path("../../templates/stage.rb.erb", __FILE__)
|
30
|
-
capfile = File.expand_path("../../templates/Capfile", __FILE__)
|
31
|
-
|
32
|
-
execute "mkdir -p #{deploy_dir}"
|
33
|
-
|
34
|
-
entries = [{template: deploy_rb, file: config_dir.join('deploy.rb')}]
|
35
|
-
entries += envs.split(',').map { |stage| {template: stage_rb, file: deploy_dir.join("#{stage}.rb")} }
|
36
|
-
|
37
|
-
entries.each do |entry|
|
38
|
-
if File.exists?(entry[:file])
|
39
|
-
warn "[skip] #{entry[:file]} already exists"
|
40
|
-
else
|
41
|
-
File.open(entry[:file], 'w+') do |f|
|
42
|
-
f.write(ERB.new(File.read(entry[:template])).result(binding))
|
43
|
-
puts "create #{entry[:file]}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
execute "mkdir -p #{tasks_dir}"
|
49
|
-
|
50
|
-
if File.exists?('Capfile')
|
51
|
-
warn "[skip] Capfile already exists"
|
52
|
-
else
|
53
|
-
FileUtils.cp(capfile, 'Capfile')
|
54
|
-
puts 'create Capfile'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
puts 'Capified'
|
59
|
-
end
|
60
|
-
end
|