unicorn-directory-watcher 0.1.0 → 0.1.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 CHANGED
@@ -1 +1,4 @@
1
- .idea
1
+ .idea
2
+ *.gem
3
+ log
4
+ tmp
@@ -3,14 +3,26 @@ PATH
3
3
  specs:
4
4
  unicorn-directory-watcher (0.1.0)
5
5
  directory_watcher (>= 1.4.0)
6
+ eventmachine (>= 0.12)
7
+ rev (>= 0.3.2)
6
8
 
7
9
  GEM
8
10
  remote: http://rubygems.org/
9
11
  specs:
10
12
  directory_watcher (1.4.0)
13
+ eventmachine (0.12.10)
14
+ iobuffer (1.0.0)
15
+ rack (1.3.1)
16
+ rev (0.3.2)
17
+ iobuffer (>= 0.1.3)
18
+ sinatra (1.2.6)
19
+ rack (~> 1.1)
20
+ tilt (>= 1.2.2, < 2.0)
21
+ tilt (1.3.2)
11
22
 
12
23
  PLATFORMS
13
24
  ruby
14
25
 
15
26
  DEPENDENCIES
27
+ sinatra (>= 1.2.6)
16
28
  unicorn-directory-watcher!
@@ -0,0 +1,26 @@
1
+ # Unicorn Directory Watcher
2
+
3
+ Unicorn wrapper that restarts the server when a file changes (inspired by http://namelessjon.posterous.com/?tag=unicorn)
4
+
5
+ ## Installation
6
+
7
+ gem install unicorn-directory-watcher
8
+
9
+ ## Usage
10
+
11
+ #!/usr/bin/env ruby
12
+ require 'rubygems'
13
+ require 'unicorn_directory_watcher'
14
+
15
+ app_name = "my-app"
16
+ root_dir = File.expand_path("#{File.dirname(__FILE__)}/..")
17
+
18
+ UnicornDirectoryWatcher.call(
19
+ app_name,
20
+ root_dir,
21
+ :watcher_globs => {
22
+ root_dir => "{app,lib,services,vendor}/**/*.rb"
23
+ }
24
+ ) do
25
+ system "unicorn -D -E development -c config/unicorn.rb config.ru"
26
+ end
@@ -7,13 +7,19 @@ module UnicornDirectoryWatcher
7
7
  end
8
8
 
9
9
  class Runner
10
- attr_reader :app_name, :root_dir, :watcher_globs
10
+ attr_reader :app_name, :root_dir, :watcher_globs, :log_dir, :pid_dir
11
11
 
12
12
  def initialize(app_name, root_dir, params={})
13
13
  @app_name, @root_dir = app_name, root_dir
14
14
  @watcher_globs = params[:watcher_globs] || {
15
15
  root_dir => "{app,lib,vendor}/**/*.rb"
16
16
  }
17
+ @log_dir = (params[:log_dir] || "#{root_dir}/log").tap do |dir|
18
+ FileUtils.mkdir_p(dir)
19
+ end
20
+ @pid_dir = (params[:pid_dir] || "#{root_dir}/tmp/pids").tap do |dir|
21
+ FileUtils.mkdir_p(dir)
22
+ end
17
23
  end
18
24
 
19
25
  def call(&block)
@@ -23,9 +29,8 @@ module UnicornDirectoryWatcher
23
29
  EM.epoll = true
24
30
  end
25
31
 
26
- FileUtils.mkdir_p("#{root_dir}/log")
27
- ENV["UNICORN_STDERR_PATH"] = "#{root_dir}/log/#{app_name}.development.stderr.log"
28
- ENV["UNICORN_STDOUT_PATH"] = "#{root_dir}/log/#{app_name}.development.stdout.log"
32
+ ENV["UNICORN_STDERR_PATH"] = "#{log_dir}/#{app_name}.development.stderr.log"
33
+ ENV["UNICORN_STDOUT_PATH"] = "#{log_dir}/#{app_name}.development.stdout.log"
29
34
 
30
35
  tail_stderr_log = fork do
31
36
  system "tail -f #{ENV["UNICORN_STDERR_PATH"]}"
@@ -37,7 +42,7 @@ module UnicornDirectoryWatcher
37
42
  # start the unicorn
38
43
  yield
39
44
 
40
- # get the pid
45
+ # get the pid
41
46
  system "touch #{pidfile}"
42
47
 
43
48
  master_pid = lambda do
@@ -89,11 +94,11 @@ module UnicornDirectoryWatcher
89
94
 
90
95
  protected
91
96
  def logfile
92
- "#{root_dir}/log/unicorn.log"
97
+ "#{log_dir}/unicorn.log"
93
98
  end
94
99
 
95
100
  def pidfile
96
- "#{root_dir}/tmp/pids/unicorn.pid"
101
+ "#{pid_dir}/unicorn.pid"
97
102
  end
98
103
  end
99
104
  end
@@ -1,3 +1,3 @@
1
1
  module UnicornDirectoryWatcher
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,5 @@
1
+ require 'sinatra'
2
+
3
+ get '/' do
4
+ "Hello World!"
5
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require "bundler"
4
+ $:.unshift(File.expand_path("#{File.dirname(__FILE__)}/../lib"))
5
+ require 'unicorn_directory_watcher'
6
+
7
+ app_name = "unicorn-watcher"
8
+ root_dir = File.expand_path("#{File.dirname(__FILE__)}/..")
9
+
10
+ UnicornDirectoryWatcher.call(
11
+ app_name,
12
+ root_dir,
13
+ :watcher_globs => {
14
+ root_dir => "{app,lib,services,vendor}/**/*.rb"
15
+ }
16
+ ) do
17
+ system "unicorn -D -E development -c config/unicorn.rb config.ru"
18
+ end
@@ -22,4 +22,8 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib"]
23
23
 
24
24
  s.add_dependency "directory_watcher", ">=1.4.0"
25
+ s.add_dependency "eventmachine", ">=0.12"
26
+ s.add_dependency "rev", ">=0.3.2"
27
+
28
+ s.add_development_dependency "sinatra", ">=1.2.6"
25
29
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: unicorn-directory-watcher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brian Takita
@@ -24,6 +24,39 @@ dependencies:
24
24
  version: 1.4.0
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: eventmachine
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0.12"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rev
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.3.2
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: sinatra
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 1.2.6
58
+ type: :development
59
+ version_requirements: *id004
27
60
  description: Unicorn wrapper that restarts the server when a file changes (inspired by http://namelessjon.posterous.com/?tag=unicorn)
28
61
  email:
29
62
  - btakita@truecar.com
@@ -38,9 +71,11 @@ files:
38
71
  - .rvmrc
39
72
  - Gemfile
40
73
  - Gemfile.lock
41
- - README
74
+ - README.md
42
75
  - lib/unicorn_directory_watcher.rb
43
76
  - lib/unicorn_directory_watcher/version.rb
77
+ - spec/config.ru
78
+ - spec/unicorn-watcher.rb
44
79
  - unicorn-directory-watcher.gemspec
45
80
  has_rdoc: true
46
81
  homepage: https://github.com/TrueCar/unicorn-directory-watcher
data/README DELETED
File without changes