alt-foreman 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3aba06eba575dc16a9e0a2d32ebc1618a9b23454
4
+ data.tar.gz: 31c2b252c0fd543f4a0da478f866d501c2adea45
5
+ SHA512:
6
+ metadata.gz: 141bbdabb9e25603d104c64609ed3fdab5b8c7ca838e4347abb913ef91a94492b048e1349ed7b3f6c124b2e66682896d51283f99d52a056bd2fee85efb93fe4b
7
+ data.tar.gz: 7b412d3cf36ded62ff4cadd648a048be888cbc2d69941ad8eeecbe4f5bca86a1f7f04b9572835786315013aea96ed29f19f9cbc08b134d55a28318122fd09f20
data/bin/alt-foreman CHANGED
@@ -11,7 +11,7 @@ is_help = ARGV.include?('-h') or ARGV.include?("--help")
11
11
 
12
12
  if is_help or is_fail
13
13
  unless is_help
14
- puts "No such file `#{ARGV[0]}'"
14
+ puts "No such file `#{pf}'"
15
15
  end
16
16
  puts "alt-foreman #{Alt::Foreman::VERSION}"
17
17
  puts "Crude alternative to foreman for local development"
@@ -19,13 +19,15 @@ if is_help or is_fail
19
19
  exit(is_help ? 0 : 1)
20
20
  end
21
21
 
22
- Dir.chdir(File.dirname(ARGV[0] || 'Procfile'))
22
+ puts "\033]0;.../#{File.basename(File.dirname(File.expand_path(pf)))} - Procfile\007"
23
+
24
+ Dir.chdir(File.dirname(pf))
23
25
 
24
26
  if File.exist?('Gemfile')
25
27
  ENV["BUNDLE_GEMFILE"]= File.expand_path("Gemfile")
26
28
  end
27
29
 
28
- processes = IO.readlines(ARGV[0]).map do |line|
30
+ processes = IO.readlines(pf).map do |line|
29
31
  line = line.chomp.gsub(/#.*$/, '')
30
32
  if line =~ /:\s+/
31
33
  Alt::Foreman::Process.new(*line.split(/:\s+/,2))
@@ -34,13 +36,29 @@ processes = IO.readlines(ARGV[0]).map do |line|
34
36
  end
35
37
  end.compact
36
38
 
39
+
40
+ kill_children = lambda do
41
+ $kill = true
42
+ STDERR.puts ""
43
+ processes.each do |process|
44
+ STDERR.puts "Sending TERM to #{process.pid} - #{process.cmd}"
45
+ Process.kill('TERM', process.pid)
46
+ end
47
+ exit
48
+ end
49
+
50
+ trap(:INT, &kill_children)
51
+ trap(:TERM, &kill_children)
52
+
37
53
  threads = processes.map do |process|
38
54
  Thread.new do
39
55
  loop do
40
56
  process.run
41
- process.log("Process #{$?.pid} `#{process.cmd}' died (#{$?.status})", :red)
42
- sleep 2
43
- process.log("`#{process.cmd}' re-spawning", :red)
57
+ unless $kill
58
+ process.log("Process #{$?.pid} `#{process.cmd}' died (#{$?.to_i})", :red)
59
+ sleep 2
60
+ process.log("`#{process.cmd}' re-spawning", :red)
61
+ end
44
62
  end
45
63
  end
46
64
  end.each { |t| t.join }
@@ -3,7 +3,7 @@ require 'shellwords'
3
3
  module Alt
4
4
  module Foreman
5
5
  class Process
6
- attr_reader :name, :cmd
6
+ attr_reader :name, :cmd, :pid
7
7
  def initialize(name, cmd)
8
8
  @name, @cmd = name, cmd
9
9
  end
@@ -21,6 +21,7 @@ module Alt
21
21
  end
22
22
 
23
23
  IO.popen(@cmd, 'rb') do |io|
24
+ @pid = io.pid
24
25
  while line = io.gets
25
26
  log(line)
26
27
  end
@@ -1,5 +1,5 @@
1
1
  module Alt
2
2
  module Foreman
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,32 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alt-foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
- - ! 'Geoff Youngs
9
-
10
- '
7
+ - |
8
+ Geoff Youngs
11
9
  autorequire:
12
10
  bindir: bin
13
11
  cert_chain: []
14
- date: 2013-01-10 00:00:00.000000000 Z
12
+ date: 2013-03-08 00:00:00.000000000 Z
15
13
  dependencies:
16
14
  - !ruby/object:Gem::Dependency
17
15
  name: term-ansicolor
18
16
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
17
  requirements:
21
- - - ! '>='
18
+ - - '>='
22
19
  - !ruby/object:Gem::Version
23
20
  version: '0'
24
21
  type: :runtime
25
22
  prerelease: false
26
23
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
24
  requirements:
29
- - - ! '>='
25
+ - - '>='
30
26
  - !ruby/object:Gem::Version
31
27
  version: '0'
32
28
  description: Lightweight procfile runner
@@ -47,26 +43,25 @@ files:
47
43
  - lib/alt-foreman/version.rb
48
44
  homepage: ''
49
45
  licenses: []
46
+ metadata: {}
50
47
  post_install_message:
51
48
  rdoc_options: []
52
49
  require_paths:
53
50
  - lib
54
51
  required_ruby_version: !ruby/object:Gem::Requirement
55
- none: false
56
52
  requirements:
57
- - - ! '>='
53
+ - - '>='
58
54
  - !ruby/object:Gem::Version
59
55
  version: '0'
60
56
  required_rubygems_version: !ruby/object:Gem::Requirement
61
- none: false
62
57
  requirements:
63
- - - ! '>='
58
+ - - '>='
64
59
  - !ruby/object:Gem::Version
65
60
  version: '0'
66
61
  requirements: []
67
62
  rubyforge_project:
68
- rubygems_version: 1.8.24
63
+ rubygems_version: 2.0.0.rc.2
69
64
  signing_key:
70
- specification_version: 3
65
+ specification_version: 4
71
66
  summary: rubbish dev version of foreman
72
67
  test_files: []