invoker 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODk1Y2NiOGY1ODllNzlkMDI3ZTAxYzg4MzBiOTQ1Nzg4MTQ3NjM3OQ==
4
+ MGY0NmQ0YjY1MzZiOWNiYjJkNzE3NjI1YTQxOTI3YTEwMGQxM2FhZQ==
5
5
  data.tar.gz: !binary |-
6
- ODE0MmVhZDAyNzQ0NWIwZTdmYjVlOWRmYzFjZDdiM2I2NzViYjE4NQ==
6
+ NGNiZDNlMTgxZjliOWVmMTdlNjI0YmFkNjUyODcwNjViNGQ5MTJlMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDAyNDNhZmYzMmE5NTg0NzFhMWRmNTEwMTM5MjdhNzA0YzAwMTZhY2QxYzRm
10
- ZWRiZmRhZjk0NGFmODU4NTMwMDgyNGNkNGVjNDA5M2I4NWEyOTYwZmEyYTVh
11
- OWMwNGU2ZmU3NTUyNGNmMGU2YzJhNTA2NzU5M2JkZWQ3NDFhOGY=
9
+ MGQxYzdhY2MxYWRhMjExM2NlNDdiYTM0OTc1YjAxZmIyYTFjMjM2YWJiMmUx
10
+ NTE3OWFiMWNiZDEwOGE0NTA2ZmUyOGI1NGYwYTAxYzYwNjM2ZTQzMzU2ODkw
11
+ Yjc5MGQxZDg4ZmQ2MTRlYWJjMTE3ZDkwODIzODYxOTkyYjM2ZmE=
12
12
  data.tar.gz: !binary |-
13
- MDVmZmQ1OWMxMGM1NTRjM2YzNzJjMjBiNjIzNDA1ZThhZDZmZDI0M2VkM2I4
14
- NDNmYjM1ZGZmYTkyOWZmNjg0NjJjOWI3ZTlmMmQ4N2RjNjU0MGVlOGFhMDZi
15
- YjE3NWUyOGU2ZjY5MjU0OWRjMmZhNmZlMjc2Njk3MWUzMTliZDI=
13
+ NmIxY2Q3NzkzM2Y0OTYxMTk4ZmJmZTIxMmI2NGRjZTkyZjdkOGU2NGZiZjhh
14
+ YmNlZDZmODdmYjE4OWIxMzY5ZDUyNDhjODU2NmIwYTA0ZjQ5YmQxNzQxZTM2
15
+ MjUyMjI1MTAyYTZlZGVjZjRkYmEwMjRjOTgwNWE4ZjBmYjIwYTE=
@@ -1,8 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
+ GEM_NAME = "invoker"
4
+
5
+ lib = File.expand_path("../lib", __FILE__)
6
+ $: << lib unless $:.include?(lib)
7
+
8
+ require "invoker/version"
9
+
3
10
  Gem::Specification.new do |s|
4
- s.name = %q{invoker}
5
- s.version = "0.0.2"
11
+ s.name = GEM_NAME
12
+ s.version = Invoker::VERSION
6
13
 
7
14
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
15
  s.authors = ["Hemant Kumar"]
@@ -1,10 +1,7 @@
1
1
  $: << File.dirname(__FILE__) unless $:.include?(File.expand_path(File.dirname(__FILE__)))
2
2
 
3
- module Invoker
4
- VERSION = "0.0.2"
5
- end
6
-
7
3
  require "colored"
4
+ require_relative "invoker/version"
8
5
  require_relative "invoker/runner"
9
6
  require_relative "invoker/command_listener"
10
7
  require_relative "invoker/errors"
@@ -156,7 +156,12 @@ module Invoker
156
156
 
157
157
  def install_interrupt_handler
158
158
  Signal.trap("INT") do
159
- @workers.each {|key,worker| Process.kill("INT", worker.pid) }
159
+ @workers.each {|key,worker|
160
+ begin
161
+ Process.kill("INT", worker.pid)
162
+ rescue Errno::ESRCH
163
+ end
164
+ }
160
165
  exit(0)
161
166
  end
162
167
  end
@@ -9,11 +9,20 @@ module Invoker
9
9
  @processes = process_ini(@ini_content)
10
10
  end
11
11
 
12
+ private
12
13
  def process_ini(ini_content)
13
14
  document = IniParse.parse(ini_content)
14
15
  document.map do |section|
16
+ check_directory(section["directory"])
15
17
  OpenStruct.new(label: section.key, dir: section["directory"], cmd: section["command"])
16
18
  end
17
19
  end
20
+
21
+ def check_directory(app_dir)
22
+ if app_dir && !app_dir.empty? && !File.directory?(app_dir)
23
+ raise Invoker::Errors::InvalidConfig.new("Invalid directory #{app_dir}")
24
+ end
25
+ end
26
+
18
27
  end
19
28
  end
@@ -0,0 +1,3 @@
1
+ module Invoker
2
+ VERSION = "0.0.3"
3
+ end
data/readme.md CHANGED
@@ -44,14 +44,24 @@ Now additionally you can control individual process by,
44
44
  # add and start running
45
45
  ~> invoker add dj
46
46
 
47
- You can also enable OSX notifications for crashed processes by installing `terminal-notification` gem. It is not a dependency, but can be useful if something crashed and you weren't paying attention.
48
-
47
+ You can also enable OSX notifications for crashed processes by installing `terminal-notification` gem. It is not a dependency, but can be useful if something crashed and you weren't paying attention.
49
48
 
50
- ## Bug reports, Feature requests ##
49
+ ## Using with rbenv or rvm ##
51
50
 
52
- Please use [Github Issue Tracker](https://github.com/code-mancers/invoker/issues) for feature requests or bug reports.
51
+ The way `rbenv` and `rvm` work sometimes creates problems when you are trying to use a process supervisor like `invoker`. There are couple of things to keep in mind,
52
+ If you are running `invoker` with Ruby version x, but your application requires Ruby version Y:
53
53
 
54
+ * When using `rbenv`, you can define the command with environment variable `RBENV_VERSION=Y` and then start your application. In other words:
55
+
56
+ command = RBENV_VERSION=2.0.0-p0 zsh -c "bundle exec rails s"
54
57
 
58
+ * Unless version of Ruby using which you are running `invoker` command and version of Ruby you are using in the application is same, you almost always will want to use
59
+ `zsh -c` or `bash -c`. `RVM` in particular requires a login shell and hence sometimes you may have to use `bash -lc`. For example:
55
60
 
61
+ command = bash -lc "rvm use 2.0.0-p0 && bundle exec rails s"
62
+
56
63
 
64
+ ## Bug reports and Feature requests
65
+
66
+ Please use [Github Issue Tracker](https://github.com/code-mancers/invoker/issues) for feature requests or bug reports.
57
67
 
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ require "tempfile"
4
+
5
+ describe "Invoker::Config" do
6
+ describe "with invalid directory" do
7
+ it "should raise error during startup" do
8
+ begin
9
+ file = Tempfile.new("invalid_config.ini")
10
+
11
+ config_data =<<-EOD
12
+ [try_sleep]
13
+ directory = /Users/gnufied/foo
14
+ command = ruby try_sleep.rb
15
+ EOD
16
+ file.write(config_data)
17
+ file.close
18
+ lambda {
19
+ Invoker::Config.new(file.path)
20
+ }.should.raise(Invoker::Errors::InvalidConfig)
21
+ ensure
22
+ file.unlink()
23
+ end
24
+ end
25
+ end
26
+ end
27
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hemant Kumar
@@ -132,10 +132,12 @@ files:
132
132
  - lib/invoker/errors.rb
133
133
  - lib/invoker/reactor.rb
134
134
  - lib/invoker/runner.rb
135
+ - lib/invoker/version.rb
135
136
  - readme.md
136
137
  - spec/invoker/command_listener/client_spec.rb
137
138
  - spec/invoker/command_worker_spec.rb
138
139
  - spec/invoker/commander_spec.rb
140
+ - spec/invoker/config_spec.rb
139
141
  - spec/spec_helper.rb
140
142
  homepage: http://github.com/code-mancers/invoker
141
143
  licenses:
@@ -165,5 +167,6 @@ test_files:
165
167
  - spec/invoker/command_listener/client_spec.rb
166
168
  - spec/invoker/command_worker_spec.rb
167
169
  - spec/invoker/commander_spec.rb
170
+ - spec/invoker/config_spec.rb
168
171
  - spec/spec_helper.rb
169
172
  has_rdoc: