upstart-exporter 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,10 +29,23 @@ class Upstart::Exporter
29
29
  return binds unless cmd
30
30
 
31
31
  parts = cmd.split /\s*(&&|\|\|)\s*/
32
- parts.last.gsub!(/\A(exec\s*|\s*)/, "exec ")
33
- cmd = parts.join(" ")
32
+ parts.push ensure_prepend_exec(parts.pop)
34
33
 
35
- binds.merge(:cmd => cmd)
34
+ binds.merge(:cmd => parts.join(" "))
35
+ end
36
+
37
+ def ensure_prepend_exec(cmd)
38
+ cmd = guard_leading_env_var(cmd.strip)
39
+ cmd.gsub(/\A(exec\s*|\s*)/, "exec ")
40
+ end
41
+
42
+ def guard_leading_env_var(cmd)
43
+ if cmd =~ /\A\S+=\S+/
44
+ warn "WARNING: Command '#{cmd}' seems to start with assignment of environment var. Prepending with 'env'"
45
+ "env #{cmd}"
46
+ else
47
+ cmd
48
+ end
36
49
  end
37
50
  end
38
51
  end
@@ -1,5 +1,5 @@
1
1
  module Upstart
2
2
  class Exporter
3
- VERSION = "2.1.1"
3
+ VERSION = "2.1.2"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ require 'spec/spec_helper'
3
3
  describe Upstart::Exporter do
4
4
  let(:tpl){ Upstart::Exporter::Templates }
5
5
 
6
- let(:exporter) do
6
+ before do
7
7
  make_global_config({
8
8
  'helper_dir' => '/h',
9
9
  'upstart_dir' => '/u',
@@ -13,6 +13,9 @@ describe Upstart::Exporter do
13
13
  'start_on_runlevel' => '[7]'
14
14
  }.to_yaml)
15
15
  make_procfile('Procfile', 'ls_cmd: ls')
16
+ end
17
+
18
+ let(:exporter) do
16
19
  exporter = described_class.new({:app_name => 'app', :procfile => 'Procfile'})
17
20
  end
18
21
 
@@ -49,6 +52,20 @@ describe Upstart::Exporter do
49
52
  :kill_timeout => 30,
50
53
  :helper_cmd_conf => '/h/p-app-ls_cmd.sh')
51
54
  end
55
+
56
+ it 'prepends with "env" command starts with env var assignment' do
57
+ make_procfile('Procfile', 'sidekiq: RAILS_ENV=production sidekiq')
58
+ exporter.export
59
+
60
+ File.read('/h/p-app-sidekiq.sh').should == tpl.helper(:cmd => 'exec env RAILS_ENV=production sidekiq')
61
+ end
62
+
63
+ it 'call to "env" will not appear twice' do
64
+ make_procfile('Procfile', 'sidekiq: env RAILS_ENV=production sidekiq')
65
+ exporter.export
66
+
67
+ File.read('/h/p-app-sidekiq.sh').should == tpl.helper(:cmd => 'exec env RAILS_ENV=production sidekiq')
68
+ end
52
69
  end
53
70
 
54
71
  describe '#clear' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upstart-exporter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 1
10
- version: 2.1.1
9
+ - 2
10
+ version: 2.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilya Averyanov
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-02-14 00:00:00 +04:00
19
+ date: 2014-02-24 00:00:00 +04:00
20
20
  default_executable:
21
21
  dependencies: []
22
22