capistrano-unicorn-methods 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v 0.0.1: Initial release.
2
+
3
+ This contains the initial release of the namespace.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-unicorn-methods.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ ## Usage
2
+
3
+ 1If you don't have one, copy the config/unicorn.rb file into your app in the app/condig/unicorn.rb path. This is the location where the gem will look for the configuration file.
4
+
5
+ After copying the file you should make sure that all the paths are changed to reflect your system setup.
6
+
7
+ If you already have a config file you should make sure that the pid file is written to shared/pids/unicorn.pid.
8
+
9
+ The gem gives you access to the followig methods within the `unicorn.<method>` namespace.
10
+
11
+ * `unicorn.start` will start the unicorn server in demonized form on port 3000 (default) with the config file placed in app/config/unicorn.rb.
12
+ * `unicorn.stop` will stop the unicorn server.
13
+ * `unicorn.restart` restarts the unicorn server by moving the old one to <somename>.pid.oldbin and running a `unicorn.cleanup` command.
14
+ * `unicorn.cleanup` will remove the master and worker processes associated with the <something>.pid.oldbin file.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "capistrano-unicorn-methods/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "capistrano-unicorn-methods"
7
+ s.version = Capistrano::Unicorn::Methods::VERSION
8
+ s.authors = ["Emil Kampp"]
9
+ s.email = ["emiltk@benjamin.dk"]
10
+ s.homepage = "http://emil.kampp.me"
11
+ s.summary = %q{Contains standadized methods for managing unicorn servers through capistrano.}
12
+ s.description = %q{Contains a unicorn namespace with methods for starting stopping and maintaining the unicorn server to serve the rails app.}
13
+
14
+ s.rubyforge_project = "capistrano-unicorn-methods"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
data/config/.DS_Store ADDED
Binary file
data/config/unicorn.rb ADDED
@@ -0,0 +1,35 @@
1
+ worker_processes 5
2
+ working_directory "/dana/data/imageupload/current"
3
+
4
+ # This loads the application in the master process before forking
5
+ # worker processes
6
+ # Read more about it here:
7
+ # http://unicorn.bogomips.org/Unicorn/Configurator.html
8
+ preload_app true
9
+
10
+ timeout 30
11
+
12
+ # This is where we specify the socket.
13
+ # We will point the upstream Nginx module to this socket later on
14
+ listen "/dana/data/imageupload/shared/sockets/unicorn.sock", :backlog => 64
15
+
16
+ pid "/dana/data/imageupload/shared/pids/unicorn.pid"
17
+
18
+ # Set the path of the log files inside the log folder of the testapp
19
+ stderr_path "/dana/data/imageupload/shared/log/unicorn.stderr.log"
20
+ stdout_path "/dana/data/imageupload/shared/log/unicorn.stdout.log"
21
+
22
+ before_fork do |server, worker|
23
+ # This option works in together with preload_app true setting
24
+ # What is does is prevent the master process from holding
25
+ # the database connection
26
+ defined?(ActiveRecord::Base) and
27
+ ActiveRecord::Base.connection.disconnect!
28
+ end
29
+
30
+ after_fork do |server, worker|
31
+ # Here we are establishing the connection after forking worker
32
+ # processes
33
+ defined?(ActiveRecord::Base) and
34
+ ActiveRecord::Base.establish_connection
35
+ end
@@ -0,0 +1,7 @@
1
+ module Capistrano
2
+ module Unicorn
3
+ module Methods
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ require "capistrano-unicorn-methods/version"
2
+ Capistrano::Configuration.instance.load do
3
+ namespace :unicorn do
4
+ desc "Zero-downtime restart of Unicorn"
5
+ task :restart, :except => { :no_release => true } do
6
+ unicorn.cleanup
7
+ run "touch #{current_release}/tmp/pids/unicorn.pid"
8
+ pid = capture("cat #{current_release}/tmp/pids/unicorn.pid").to_i
9
+ run "kill -s USR2 #{pid}" if pid > 0
10
+ end
11
+
12
+ desc "Starts unicorn"
13
+ task :start, :except => { :no_release => true } do
14
+ unicorn.cleanup
15
+ run "cd #{current_release} ; bundle exec unicorn_rails -c #{current_release}/config/unicorn.rb -D -p 3000"
16
+ end
17
+
18
+ desc "Stop unicorn"
19
+ task :stop, :except => { :no_release => true } do
20
+ run "touch #{current_release}/tmp/pids/unicorn.pid"
21
+ pid = capture("cat #{current_release}/tmp/pids/unicorn.pid").to_i
22
+ run "kill -s QUIT #{pid}" if pid > 0
23
+ end
24
+
25
+ desc "Cleans up the old unicorn processes"
26
+ task :cleanup do
27
+ run "touch #{current_release}/tmp/pids/unicorn.pid.oldbin"
28
+ pid = capture("cat #{current_release}/tmp/pids/unicorn.pid.oldbin").to_i
29
+ run "kill -s QUIT #{pid}" if pid > 0
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-unicorn-methods
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Emil Kampp
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-23 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Contains a unicorn namespace with methods for starting stopping and maintaining
15
+ the unicorn server to serve the rails app.
16
+ email:
17
+ - emiltk@benjamin.dk
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - README.md
26
+ - Rakefile
27
+ - capistrano-unicorn-methods.gemspec
28
+ - config/.DS_Store
29
+ - config/unicorn.rb
30
+ - lib/capistrano-unicorn-methods.rb
31
+ - lib/capistrano-unicorn-methods/version.rb
32
+ homepage: http://emil.kampp.me
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project: capistrano-unicorn-methods
52
+ rubygems_version: 1.8.15
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Contains standadized methods for managing unicorn servers through capistrano.
56
+ test_files: []