procodile 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f9970119b9f9480ad0894234851c37b852fa29b
4
- data.tar.gz: 22e30024ec12580a2469d89520c28a03465e4e49
3
+ metadata.gz: b81b8bba13398ec47594e50c91ad24c721306874
4
+ data.tar.gz: a8ffc4cdeae8f6804469bf556587826f65562afa
5
5
  SHA512:
6
- metadata.gz: 70036e03d4e9940d8460540302b91ebd0d94d70dfac2a8d73bf4ad29a4753bc9a4ed2c5e3c35f69bc7bdb4e707c019c86138da406ada41774f66c189a98bd79e
7
- data.tar.gz: b8740fbfa8d2ceff5b0f053abef7e8958f934f1d7aaf636aeb18e3195685f58246166c82afd7f87178f4c8f31b3c372df5650236972e448b860609cfc15184f3
6
+ metadata.gz: 862ab4fcfd46b29cfcb882ff9f4e7c88e418b743797924f4fd6315ac70ae7c3052f11f75cbd355c5a962c6e067d4c67f4d564db59c798d96dfe0bf7d954b3e21
7
+ data.tar.gz: 293bab2e09493cefb4162a46f1b9804fa69eb0899547beaec6f83d52a01c47619e7c4eec8e6ccb267a49a7bd09b88f112aaddff3f92036c42ed0b38030c59b35
@@ -71,11 +71,11 @@ module Procodile
71
71
 
72
72
  def find_root_and_procfile(pwd, root, procfile)
73
73
  if root && procfile
74
- # The user has provided both the root and procfile, we can use these
74
+ # The user has provided both the root and procfile, we can use these
75
75
  @root = expand_path(root)
76
76
  @procfile = expand_path(procfile, @root)
77
77
  elsif root && procfile.nil?
78
- # The user has given us a root, we can assume they want to use the procfile
78
+ # The user has given us a root, we can assume they want to use the procfile
79
79
  # from the root
80
80
  @root = expand_path(root)
81
81
  @procfile = File.join(@root, 'Procfile')
@@ -117,7 +117,7 @@ module Procodile
117
117
  path
118
118
  else
119
119
  # Otherwise, if there's a root provided, it should be from the root
120
- # of that otherwise from the root of the current directory.
120
+ # of that otherwise from the root of the current directory.
121
121
  root ? File.join(root, path) : File.join(@pwd, path)
122
122
  end
123
123
  end
data/lib/procodile/cli.rb CHANGED
@@ -63,7 +63,7 @@ module Procodile
63
63
  end
64
64
 
65
65
  #
66
- # Start
66
+ # Start
67
67
  #
68
68
 
69
69
  desc "Starts processes and/or the supervisor"
@@ -148,7 +148,7 @@ module Procodile
148
148
  return
149
149
  else
150
150
  # The supervisor isn't actually running. We need to start it before processes can be
151
- # begin being processed
151
+ # begin being processed
152
152
  if @options[:start_supervisor] == false
153
153
  raise Error, "Supervisor is not running and cannot be started because --no-supervisor is set"
154
154
  else
@@ -162,7 +162,7 @@ module Procodile
162
162
  end
163
163
 
164
164
  #
165
- # Stop
165
+ # Stop
166
166
  #
167
167
 
168
168
  desc "Stops processes and/or the supervisor"
@@ -7,7 +7,7 @@ module Procodile
7
7
  attr_reader :id
8
8
  attr_accessor :process
9
9
  attr_reader :tag
10
- attr_reader :port
10
+ attr_accessor :port
11
11
 
12
12
  def initialize(supervisor, process, id)
13
13
  @supervisor = supervisor
@@ -25,7 +25,7 @@ module Procodile
25
25
  end
26
26
 
27
27
  #
28
- # Return the status of this instance
28
+ # Return the status of this instance
29
29
  #
30
30
  def status
31
31
  if stopped?
@@ -119,12 +119,18 @@ module Procodile
119
119
  Procodile.log(@process.log_color, description, "Assigned #{chosen_port} to process")
120
120
  end
121
121
  elsif @process.proxy? && @supervisor.tcp_proxy
122
- # Allocate a port randomly if a proxy is needed
123
- allocate_port
124
- end
125
-
126
- if (@supervisor.run_options[:allocate_ports] && @supervisor.run_options[:allocate_ports].include?(@process.name)) || (@process.proxy? && @supervisor.tcp_proxy)
122
+ # Allocate a port randomly if a proxy is needed
127
123
  allocate_port
124
+ elsif @process.allocate_port_from && @process.restart_mode != 'start-term'
125
+ # Allocate ports to this process sequentially from the starting port
126
+ allocated_ports = (@supervisor.processes[@process] ? @supervisor.processes[@process].select(&:running?) : []).map(&:port)
127
+ proposed_port = @process.allocate_port_from
128
+ until @port
129
+ unless allocated_ports.include?(proposed_port)
130
+ @port = proposed_port
131
+ end
132
+ proposed_port += 1
133
+ end
128
134
  end
129
135
 
130
136
  if self.process.log_path && @supervisor.run_options[:force_single_log] != true
@@ -160,7 +166,7 @@ module Procodile
160
166
  end
161
167
 
162
168
  #
163
- # Is this stopped?
169
+ # Is this stopped?
164
170
  #
165
171
  def stopped?
166
172
  @stopped || false
@@ -221,7 +227,9 @@ module Procodile
221
227
  else
222
228
  Procodile.log(@process.log_color, description, "Process not running already. Starting it.")
223
229
  on_stop
224
- @process.create_instance(@supervisor).start
230
+ new_instance = @process.create_instance(@supervisor)
231
+ new_instance.port = self.port
232
+ new_instance.start
225
233
  end
226
234
  self
227
235
  when 'start-term'
@@ -232,6 +240,7 @@ module Procodile
232
240
  when 'term-start'
233
241
  stop
234
242
  new_instance = @process.create_instance(@supervisor)
243
+ new_instance.port = self.port
235
244
  Thread.new do
236
245
  sleep 0.5 while running?
237
246
  new_instance.start
@@ -354,7 +363,7 @@ module Procodile
354
363
  end
355
364
 
356
365
  #
357
- # Is the given port available?
366
+ # Is the given port available?
358
367
  #
359
368
  def port_available?(port)
360
369
  case @process.network_protocol
@@ -375,8 +384,8 @@ module Procodile
375
384
  end
376
385
 
377
386
  #
378
- # If procodile is executed through rbenv it will pollute our environment which means that
379
- # any spawned processes will be invoked with procodile's ruby rather than the ruby that
387
+ # If procodile is executed through rbenv it will pollute our environment which means that
388
+ # any spawned processes will be invoked with procodile's ruby rather than the ruby that
380
389
  # the application wishes to use
381
390
  #
382
391
  def without_rbenv(&block)
@@ -81,7 +81,7 @@ module Procodile
81
81
 
82
82
  #
83
83
  # Return the log path for this process if no log path is provided and split logs
84
- # is enabled
84
+ # is enabled
85
85
  #
86
86
  def default_log_path
87
87
  if @config.log_root
@@ -92,7 +92,7 @@ module Procodile
92
92
  end
93
93
 
94
94
  #
95
- # Return the signal to send to terminate the process
95
+ # Return the signal to send to terminate the process
96
96
  #
97
97
  def term_signal
98
98
  @options['term_signal'] || 'TERM'
@@ -102,7 +102,7 @@ module Procodile
102
102
  # Defines how this process should be restarted
103
103
  #
104
104
  # start-term = start new instances and send term to children
105
- # usr1 = just send a usr1 signal to the current instance
105
+ # usr1 = just send a usr1 signal to the current instance
106
106
  # usr2 = just send a usr2 signal to the current instance
107
107
  # term-start = stop the old instances, when no longer running, start a new one
108
108
  #
@@ -110,6 +110,13 @@ module Procodile
110
110
  @options['restart_mode'] || 'term-start'
111
111
  end
112
112
 
113
+ #
114
+ # Return the first port that ports should be allocated from for this process
115
+ #
116
+ def allocate_port_from
117
+ @options['allocate_port_from']
118
+ end
119
+
113
120
  #
114
121
  # Is this process enabled for proxying?
115
122
  #
@@ -132,7 +139,7 @@ module Procodile
132
139
  end
133
140
 
134
141
  #
135
- # Return the network protocol for this process
142
+ # Return the network protocol for this process
136
143
  #
137
144
  def network_protocol
138
145
  @options['network_protocol'] || 'tcp'
@@ -1,3 +1,3 @@
1
1
  module Procodile
2
- VERSION = '1.0.16'
2
+ VERSION = '1.0.17'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procodile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-02 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json