procodile 1.0.16 → 1.0.17
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.
- checksums.yaml +4 -4
- data/lib/procodile/app_determination.rb +3 -3
- data/lib/procodile/cli.rb +3 -3
- data/lib/procodile/instance.rb +21 -12
- data/lib/procodile/process.rb +11 -4
- data/lib/procodile/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b81b8bba13398ec47594e50c91ad24c721306874
|
4
|
+
data.tar.gz: a8ffc4cdeae8f6804469bf556587826f65562afa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
165
|
+
# Stop
|
166
166
|
#
|
167
167
|
|
168
168
|
desc "Stops processes and/or the supervisor"
|
data/lib/procodile/instance.rb
CHANGED
@@ -7,7 +7,7 @@ module Procodile
|
|
7
7
|
attr_reader :id
|
8
8
|
attr_accessor :process
|
9
9
|
attr_reader :tag
|
10
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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)
|
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
|
-
#
|
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
|
-
#
|
379
|
-
#
|
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)
|
data/lib/procodile/process.rb
CHANGED
@@ -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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
142
|
+
# Return the network protocol for this process
|
136
143
|
#
|
137
144
|
def network_protocol
|
138
145
|
@options['network_protocol'] || 'tcp'
|
data/lib/procodile/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|