capistrano-uwsgi 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ea57ef6cc6c3f5a10c8d36e2b6ad10acaaad7aa9
4
+ data.tar.gz: 7d14da3559923b95bf55e91bef3e26205b712774
5
+ SHA512:
6
+ metadata.gz: 909d93572f69c7fa5db3d01496a60d55bc9425e75582ada8ef25e0df525c4f17989690bb0dbdb347e100adb315644b3eb91ffe2f94785f9c5a6fb7d6dcd14ae4
7
+ data.tar.gz: b3343491bd39b3c700ec5edf5514488fd9fd05628a33d70d93f4645e84fa30ecdeaa9d86991e67d131b5822dc0256a5a1f292e0600db0116eda9228b71e3cf57
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-uwsgi.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Ivan Tkalin
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.
@@ -0,0 +1,70 @@
1
+ # Capistrano::Uwsgi
2
+
3
+
4
+ This gem provides two capistrano tasks:
5
+
6
+ * `uwsgi:setup` - creates `/etc/uwsgi/apps-enabled/#{application}-#{stage}.ini`
7
+ * `uwsgi:restart` - touches `uwsgi_ini` (see below)
8
+
9
+ And uWSGI configuration file generator, that will create local copy of default uWSGI config for customization.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'capistrano-uwsgi'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install capistrano-uwsgi
24
+
25
+ ## Usage
26
+
27
+ Add this to your `config/deploy.rb` file:
28
+
29
+ require 'capistrano/uwsgi/tasks'
30
+
31
+ Make sure, following variables are defined in your `config/deploy.rb`:
32
+
33
+ * `application` - application name
34
+ * `stage` - the stage (usually from `capistrano/ext/multistage`)
35
+ * `user` - remote user name
36
+ * `group` - remote group name
37
+ * `rack_env` - RACK_ENV used to run the app
38
+ * `deploy_to` - deployment path
39
+ * `uwsgi_mode` - can be either `:standalone` or `:emperor`
40
+ * `app_port` - application port (required by the `:standalone` mode)
41
+ * `rvm_path` - set this var to enable rvm usage inside uWSGI (optional)
42
+ * `uwsgi_ini` - the path of the _compiled_ uwsgi.ini config file (optional, defaults to: `/etc/uwsgi/apps-enabled/#{application}-#{stage}.ini`)
43
+
44
+ Launch new tasks:
45
+
46
+ $ cap uwsgi:setup
47
+ $ cap uwsgi:restart
48
+
49
+ Or you can add hook to call this tasks after `deploy:setup`. Add to your `config/deploy.rb`:
50
+
51
+ after 'deploy:setup', 'uwsgi:setup', 'uwsgi:restart'
52
+
53
+ If you want to customize uWSGI configuration, just generate local uWSGI config before running `uwsgi:setup`:
54
+
55
+ $ rails generate capistrano:uwsgi:config
56
+
57
+ And then edit file `config/uwsgi.ini.erb` as you like.
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
66
+
67
+
68
+ ## Credits
69
+
70
+ Original project structure and README from [Ivan Tkalin's capistrano-nginx](https://github.com/ivalkeen/capistrano-nginx).
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ desc 'Default: run unit tests.'
5
+ task :default => :test
6
+
7
+ desc 'Run tests'
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << 'lib'
10
+ t.libs << 'test'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/uwsgi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capistrano-uwsgi'
8
+ spec.version = Capistrano::Uwsgi::VERSION
9
+ spec.authors = ['Elia Schito']
10
+ spec.email = ['elia@schito.me']
11
+ spec.description = %q{Simple uWSGI management with capistrano}
12
+ spec.summary = %q{Configuration and managements capistrano tasks for uWSGI}
13
+ spec.homepage = 'https://github.com/elia/capistrano-uwsgi'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'capistrano', ['>= 2.15.5', '< 3']
22
+ spec.add_dependency 'railties', ['>= 3.2.14', '< 5']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,6 @@
1
+ require 'capistrano/uwsgi/version'
2
+
3
+ module Capistrano
4
+ module Uwsgi
5
+ end
6
+ end
@@ -0,0 +1,35 @@
1
+ Capistrano::Configuration.instance.load do
2
+ set(:uwsgi_ini) { "/etc/uwsgi/apps-enabled/#{application}-#{stage}.ini" }
3
+
4
+ namespace :uwsgi do
5
+ desc 'Setup application in uwsgi'
6
+ task :setup, :role => :web do
7
+ config_file = 'config/uwsgi.ini.erb'
8
+ unless File.exists?(config_file)
9
+ config_file = File.expand_path('../../../generators/capistrano/uwsgi/templates/_uwsgi_conf.ini.erb', __FILE__)
10
+ end
11
+ config = ERB.new(File.read(config_file)).result(binding)
12
+ set :user, sudo_user
13
+ temp_file = '/tmp/#{application}-#{$$}-#{Time.now.to_i}'
14
+ put config, temp_name
15
+ run "#{sudo} mv /tmp/#{application} /etc/uwsgi/sites-available/#{application}"
16
+ run "#{sudo} ln -fs /etc/uwsgi/sites-available/#{application} /etc/uwsgi/sites-enabled/#{application}"
17
+
18
+
19
+
20
+ uwsgi_config = <<-INI
21
+ INI
22
+ conf_name = File.basename(uwsgi_ini)
23
+ tmp_name = "/tmp/#{conf_name}"
24
+ sudo "rm #{tmp_name} || true"
25
+ put uwsgi_config, tmp_name
26
+ sudo "mv -f #{tmp_name} #{uwsgi_ini}"
27
+ end
28
+
29
+ desc "Reload uwsgi configuration"
30
+ task :reload, :role => :web do
31
+ set :user, sudo_user
32
+ run "#{sudo} /etc/init.d/uwsgi reload"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Uwsgi
3
+ VERSION = '0.0.1.pre'
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ To create local uwsgi configuration file call
2
+
3
+ rails generate capistrano:uwsgi:config
@@ -0,0 +1,14 @@
1
+ module Capistrano
2
+ module Uwsgi
3
+ module Generators
4
+ class ConfigGenerator < Rails::Generators::Base
5
+ desc 'Create local uwsgi configuration file for customization'
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def copy_template
9
+ copy_file '_uwsgi_conf.ini.erb', 'config/uwsgi.ini.erb'
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,52 @@
1
+ [uwsgi]
2
+ deploy_to = <%= deploy_to %>
3
+ app_name = <%= application %>
4
+ uid = <%= user %>
5
+ gid = <%= group %>
6
+ env = RACK_ENV=<%= rails_env %>
7
+
8
+ ; Generic config
9
+ chdir = %(deploy_to)/current
10
+ processes = 2
11
+ harakiri = 30
12
+ buffer-size = 25000
13
+ post-buffering = 4096
14
+ disable-logging = true
15
+ rack = config.ru
16
+
17
+ <% case uwsgi_mode %>
18
+ <% when :emperor %>
19
+ ; Emperor mode
20
+ socket-modifier1 = 7
21
+ socket = %(chdir)/tmp/sockets/uwsgi.sock
22
+ pidfile = %(chdir)/tmp/pids/uwsgi.pid
23
+ daemonize = %(chdir)/log/uwsgi.log
24
+ <% when :standalone %>
25
+ ; Standalone/Proxy-Pass mode
26
+ http-socket-modifier1 = 7
27
+ env = PORT=<%= app_port %>
28
+ http-socket = :$(PORT)
29
+ die-on-term = true
30
+ master = true
31
+ <% end %>
32
+
33
+ ; Bundler
34
+ env = BUNDLE_GEMFILE=%(chdir)/Gemfile
35
+ rbrequire = rubygems
36
+ rbrequire = bundler/setup
37
+
38
+ ; RVM
39
+ <% if fetch(:rvm_path, nil) %>
40
+ rvm-path = <%= rvm_path %>
41
+ <% end %>
42
+
43
+ ; Memory management
44
+ ; report memory usage inside logs
45
+ ; memory-report = true
46
+ ; reload if the rss memory is higher than 100M
47
+ ; reload-on-rss = 100
48
+
49
+ ; Background jobs
50
+ ; E.g. attach a sidekiq worker:
51
+ ; attach-daemon = bundle exec sidekiq -c 3 -e ${RACK_ENV}
52
+
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+ require 'rails/generators/test_case'
3
+ require 'generators/capistrano/uwsgi/config_generator'
4
+
5
+ class GeneratorTest < Rails::Generators::TestCase
6
+ tests Capistrano::Uwsgi::Generators::ConfigGenerator
7
+ destination File.expand_path('../../tmp', __FILE__)
8
+ setup :prepare_destination
9
+ teardown { rm_rf(destination_root) }
10
+
11
+ def test_generates_local_config_file
12
+ run_generator
13
+ assert_file 'config/uwsgi.ini.erb'
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ require 'capistrano'
4
+
5
+ class TasksTest < Test::Unit::TestCase
6
+ def setup
7
+ @config = Capistrano::Configuration.new
8
+ Capistrano::Configuration.instance = @config
9
+ task = @config.find_task("uwsgi:setup")
10
+ load 'capistrano/uwsgi/tasks.rb'
11
+ end
12
+
13
+ def test_add_setup_task
14
+ namespace = @config.namespaces[:uwsgi]
15
+ assert_not_nil namespace
16
+ setup_task = namespace.tasks[:setup]
17
+ assert_not_nil setup_task
18
+ end
19
+
20
+ def test_add_reload_task
21
+ namespace = @config.namespaces[:uwsgi]
22
+ assert_not_nil namespace
23
+ setup_task = namespace.tasks[:reload]
24
+ assert_not_nil setup_task
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'test/unit'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-uwsgi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Elia Schito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-16 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: 2.15.5
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.15.5
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: railties
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 3.2.14
40
+ - - <
41
+ - !ruby/object:Gem::Version
42
+ version: '5'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: 3.2.14
50
+ - - <
51
+ - !ruby/object:Gem::Version
52
+ version: '5'
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '1.3'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: '1.3'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ description: Simple uWSGI management with capistrano
82
+ email:
83
+ - elia@schito.me
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
89
+ - Gemfile
90
+ - LICENSE.txt
91
+ - README.md
92
+ - Rakefile
93
+ - capistrano-uwsgi.gemspec
94
+ - lib/capistrano/uwsgi.rb
95
+ - lib/capistrano/uwsgi/tasks.rb
96
+ - lib/capistrano/uwsgi/version.rb
97
+ - lib/generators/capistrano/uwsgi/USAGE
98
+ - lib/generators/capistrano/uwsgi/config_generator.rb
99
+ - lib/generators/capistrano/uwsgi/templates/_uwsgi_conf.ini.erb
100
+ - test/generator_test.rb
101
+ - test/tasks_test.rb
102
+ - test/test_helper.rb
103
+ homepage: https://github.com/elia/capistrano-uwsgi
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>'
119
+ - !ruby/object:Gem::Version
120
+ version: 1.3.1
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.1.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Configuration and managements capistrano tasks for uWSGI
127
+ test_files:
128
+ - test/generator_test.rb
129
+ - test/tasks_test.rb
130
+ - test/test_helper.rb