webflow_cap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15be3ae93655a885349de3e117bb7f60ef3ae1ea
4
+ data.tar.gz: 084bd22e51c1e805564858949d0adbefb1ff601c
5
+ SHA512:
6
+ metadata.gz: cde6c023010cca280716252b10a02e6ac84aaa9d5167c725abe3ba9d406c087141a6841433bd200c9960b951ffa3733ec50c05f0e5ff7fe9c7947dfb7e17dd2b
7
+ data.tar.gz: 60975048aca0d978efb695c172d1ef9a19b269eab4ae08b83c1f166c6d2d58a0b148861c3f84cde6091d3770e7b157a0ee3468a16b32165948d72dd15bf02eaa
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Florian Aman, webflow GmbH
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # webflow_cap
2
+
3
+ ## License
4
+
5
+ MIT; Copyright (c) 2014 Florian Aman, webflow GmbH
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+
13
+ ## Contributing
14
+
15
+ 1. Fork it
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
17
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
18
+ 4. Push to the branch (`git push origin my-new-feature`)
19
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,93 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ # variables with default values
4
+ set :application_server, fetch(:application_server, "puma")
5
+ set :branch, fetch(:branch, "master")
6
+ set :scm, fetch(:scm, :git)
7
+
8
+ # variables without default values
9
+ set :deploy_via, :remote_cache
10
+ set :keep_releases, 3
11
+ set :use_sudo, false
12
+
13
+ set :home, -> { "/docs/#{fetch :user}" }
14
+ set :deploy_to, -> { "/docs/#{fetch :user}/#{fetch :domain}/#{fetch :application}" }
15
+ set :server_port, -> { 10000 + ((fetch :user)[3..6] + "0").to_i }
16
+
17
+ set :default_env, {
18
+ 'PATH' => "PATH=/docs/#{fetch :user}/.gem/ruby/2.1/bin:/opt/ruby/2.1/bin:$PATH"
19
+ }
20
+ end
21
+ end
22
+
23
+ namespace :runit do
24
+ task :setup_application_server do
25
+ on roles :all do
26
+ daemon_script = <<-EOF
27
+ #!/bin/bash -e
28
+ export HOME=#{fetch :home}
29
+ source $HOME/.bashrc
30
+ cd #{fetch :deploy_to}/current
31
+ exec bundle exec #{fetch :application_server} start -p #{fetch :server_port} -e production -d 2>&1
32
+ EOF
33
+
34
+ log_script = <<-EOF
35
+ #!/bin/bash -e
36
+ exec svlogd -tt ./main
37
+ EOF
38
+
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}"
46
+ end
47
+ end
48
+
49
+ after 'deploy:started', 'runit:setup_application_server'
50
+ end
51
+
52
+ namespace :apache do
53
+ task :setup_reverse_proxy do
54
+ on roles :all do
55
+ htaccess = <<-EOF
56
+ RewriteEngine On
57
+ RewriteRule ^(.*)$ http://localhost:#{fetch :server_port}/$1 [P]
58
+ EOF
59
+ path = "#{fetch :home}/#{fetch :domain}"
60
+ execute "mkdir -p #{path}"
61
+ upload! StringIO.new(htaccess), "#{path}/.htaccess"
62
+ execute "chmod +r #{path}/.htaccess"
63
+ end
64
+ end
65
+
66
+ after 'deploy:started', 'apache:setup_reverse_proxy'
67
+ end
68
+
69
+ namespace :deploy do
70
+ task :start do
71
+ on roles :all do
72
+ execute "sv start #{fetch :home}/etc/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
73
+ end
74
+ end
75
+ task :stop do
76
+ on roles :all do
77
+ execute "sv stop #{fetch :home}/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
78
+ end
79
+ end
80
+ task :restart do
81
+ on roles :all do
82
+ execute "sv restart #{fetch :home}/service/rails-#{fetch :server_port}-#{fetch :domain}-#{fetch :application}"
83
+ end
84
+ end
85
+
86
+ task :symlink_shared do
87
+ on roles :all do
88
+ execute "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
89
+ end
90
+ end
91
+
92
+ before :updated, :symlink_shared
93
+ end
@@ -0,0 +1,33 @@
1
+ namespace :mysql do
2
+ task :setup_database_and_config do
3
+ on roles :all do
4
+ my_cnf = capture('cat ~/.my.cnf')
5
+ config = {}
6
+ %w(development production test).each do |env|
7
+
8
+ my_cnf.match(/^user=(\w+)/)
9
+ database_user = $1
10
+
11
+ config[env] = {
12
+ 'adapter' => 'mysql2',
13
+ 'encoding' => 'utf8',
14
+ 'database' => "#{database_user}_#{fetch :application}_#{env}",
15
+ 'host' => 'localhost',
16
+ 'port' => 3306
17
+ }
18
+
19
+ config[env]['username'] = database_user
20
+
21
+ my_cnf.match(/^password=(\w+)/)
22
+ config[env]['password'] = $1
23
+
24
+ execute "mysql -e 'CREATE DATABASE IF NOT EXISTS #{config[env]['database']} CHARACTER SET utf8 COLLATE utf8_general_ci;'"
25
+ end
26
+
27
+ execute "mkdir -p #{:shared_path}/config"
28
+ upload! StringIO.new(config.to_yaml), "#{:shared_path}/config/database.yml"
29
+ end
30
+ end
31
+
32
+ after 'deploy:started', 'mysql:setup_database_and_config'
33
+ end
@@ -0,0 +1,2 @@
1
+ load File.expand_path("../capistrano/tasks/base.rake", __FILE__)
2
+ load File.expand_path("../capistrano/tasks/mysql.rake", __FILE__)
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Florian Aman"]
5
+ gem.license = 'MIT'
6
+ gem.email = ["fa@webflow.de"]
7
+ gem.description = %q{Deploy Rails apps}
8
+ gem.summary = %q{webflow_cap is used to deploy Ruby on Rails Applications}
9
+ gem.homepage = "https://rubygems.org/gems/webflow_cap"
10
+
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "webflow_cap"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = "0.0.1"
17
+
18
+ # dependencies
19
+ gem.add_dependency 'capistrano', '~>3.2'
20
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webflow_cap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Florian Aman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ description: Deploy Rails apps
28
+ email:
29
+ - fa@webflow.de
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/capistrano/tasks/base.rake
39
+ - lib/capistrano/tasks/mysql.rake
40
+ - lib/webflow_cap.rb
41
+ - webflow_cap.gemspec
42
+ homepage: https://rubygems.org/gems/webflow_cap
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.2.2
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: webflow_cap is used to deploy Ruby on Rails Applications
66
+ test_files: []