flame_server_toys 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/lib/flame_server_toys/template/_base.rb +5 -40
- data/lib/flame_server_toys/template/status.rb +0 -4
- data/lib/flame_server_toys/template/stop.rb +0 -2
- data/lib/flame_server_toys/version.rb +1 -1
- metadata +14 -15
- data/lib/flame_server_toys/template/_pids_file.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7430614acb1e7abe6a1f8bcaa9c7e281ba077a3cb0288db3ce559f8021100edf
|
4
|
+
data.tar.gz: fda0da85de411f6aed5df4d19289d0bdf3d8047500c776ee0ef8b94f69a16cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6829b8e3cdfd47b6230e40fc4faca0cb396f228405c95a9ba2f95f683922f81155ac6e6481b8d7301f68ab89483940524f8046d83366e6d805e7c483d58fa5c1
|
7
|
+
data.tar.gz: b8160d1cd665669a22e7a8bdf8d007d113eeab6c73af839b257b3f66f098272642f3d1f33656f2eed47d2f9588381727e846e4656d78c0a7a43d46626c99e810
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -45,7 +45,8 @@ expand FlameServerToys::Template,
|
|
45
45
|
```
|
46
46
|
|
47
47
|
On `start` and `restart` commands in `development` environment there will be spawned
|
48
|
-
|
48
|
+
`Filewatcher`s from `filewatcher.yaml` file
|
49
|
+
via [`filewatcher-matrix`](https://github.com/filewatcher/filewatcher-matrix).
|
49
50
|
|
50
51
|
## Development
|
51
52
|
|
@@ -3,8 +3,6 @@
|
|
3
3
|
require 'memery'
|
4
4
|
require 'yaml'
|
5
5
|
|
6
|
-
require_relative '_pids_file'
|
7
|
-
|
8
6
|
module FlameServerToys
|
9
7
|
class Template
|
10
8
|
## Base class for toys
|
@@ -33,11 +31,6 @@ module FlameServerToys
|
|
33
31
|
super sh_command(command), **options
|
34
32
|
end
|
35
33
|
|
36
|
-
def sh_spawn(command, print: true)
|
37
|
-
puts "spawn #{command}" if print
|
38
|
-
spawn sh_command(command), pgroup: true
|
39
|
-
end
|
40
|
-
|
41
34
|
def sh_command(command)
|
42
35
|
require 'shellwords'
|
43
36
|
|
@@ -51,11 +44,6 @@ module FlameServerToys
|
|
51
44
|
sh "#{context_directory}/exe/setup/ruby.sh"
|
52
45
|
sh("#{context_directory}/exe/setup/node.sh") if %i[start restart].include?(command)
|
53
46
|
|
54
|
-
if %i[stop restart].include?(command)
|
55
|
-
filewatcher_pids_file = pids_file_class.new(:filewatcher)
|
56
|
-
filewatcher_pids_file.kill_each.delete
|
57
|
-
end
|
58
|
-
|
59
47
|
web_server(command)
|
60
48
|
end
|
61
49
|
|
@@ -77,29 +65,15 @@ module FlameServerToys
|
|
77
65
|
spawn_development_filewatchers
|
78
66
|
|
79
67
|
puma_command File.exist?(@config[:server][:puma_pid_file]) ? 'restart' : 'start'
|
80
|
-
rescue SystemExit, Interrupt => e
|
81
|
-
pids_file_class.new(:filewatcher).kill_each.delete
|
82
|
-
|
83
|
-
raise e
|
84
68
|
end
|
85
69
|
|
86
70
|
def spawn_development_filewatchers
|
87
|
-
|
88
|
-
YAML.load_file("#{context_directory}/filewatchers.yaml").map do |args|
|
89
|
-
filewatcher_command args[:pattern], args[:command], exclude: args[:exclude]
|
90
|
-
end
|
91
|
-
|
92
|
-
filewatcher_pids = development_filewatchers.map { |command| sh_spawn command }
|
71
|
+
require 'filewatcher/matrix'
|
93
72
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
## Don't use `bundle exec`, it's already required by `toys`
|
99
|
-
## https://github.com/dazuma/toys/issues/65
|
100
|
-
<<-CMD.split.join(' ')
|
101
|
-
filewatcher #{"--exclude '#{exclude}'" unless exclude.nil?} '#{pattern}' '#{execute}'
|
102
|
-
CMD
|
73
|
+
Thread.new do
|
74
|
+
matrix = Filewatcher::Matrix.new("#{context_directory}/filewatchers.yaml")
|
75
|
+
matrix.start
|
76
|
+
end
|
103
77
|
end
|
104
78
|
|
105
79
|
def waiting_mailing_lock
|
@@ -109,15 +83,6 @@ module FlameServerToys
|
|
109
83
|
sleep 1
|
110
84
|
end
|
111
85
|
end
|
112
|
-
|
113
|
-
memoize def pids_file_class
|
114
|
-
subclass = Class.new(PidsFile)
|
115
|
-
pids_dir = @config[:pids_dir]
|
116
|
-
subclass.class_exec do
|
117
|
-
self.pids_dir = pids_dir
|
118
|
-
end
|
119
|
-
subclass
|
120
|
-
end
|
121
86
|
end
|
122
87
|
end
|
123
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flame_server_toys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alt_memery
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: filewatcher-
|
28
|
+
name: filewatcher-matrix
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
33
|
+
version: 0.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0
|
40
|
+
version: 0.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gorilla_patch
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.5.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.5.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: toys
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,28 +156,28 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.20.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.20.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rubocop
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: '1.0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: '1.0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: rubocop-performance
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '
|
201
|
+
version: '2.0'
|
202
202
|
type: :development
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
208
|
+
version: '2.0'
|
209
209
|
description: 'Toys for Flame web application server management, like start, stop,
|
210
210
|
restart, etc.
|
211
211
|
|
@@ -222,7 +222,6 @@ files:
|
|
222
222
|
- lib/flame_server_toys.rb
|
223
223
|
- lib/flame_server_toys/template.rb
|
224
224
|
- lib/flame_server_toys/template/_base.rb
|
225
|
-
- lib/flame_server_toys/template/_pids_file.rb
|
226
225
|
- lib/flame_server_toys/template/monitor.rb
|
227
226
|
- lib/flame_server_toys/template/phased_restart.rb
|
228
227
|
- lib/flame_server_toys/template/restart.rb
|
@@ -252,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
252
251
|
- !ruby/object:Gem::Version
|
253
252
|
version: '0'
|
254
253
|
requirements: []
|
255
|
-
rubygems_version: 3.1.
|
254
|
+
rubygems_version: 3.1.4
|
256
255
|
signing_key:
|
257
256
|
specification_version: 4
|
258
257
|
summary: Toys for Flame web application server management
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'English'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
module FlameServerToys
|
7
|
-
class Template
|
8
|
-
## Class for pids files
|
9
|
-
class PidsFile
|
10
|
-
class << self
|
11
|
-
## It will be set in the Base template from received config
|
12
|
-
attr_accessor :pids_dir
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(name, *pids)
|
16
|
-
@file = File.join self.class.pids_dir, "#{name}.pids"
|
17
|
-
@pids = pids.any? ? pids : read
|
18
|
-
end
|
19
|
-
|
20
|
-
def dump(pids = @pids)
|
21
|
-
FileUtils.mkdir_p self.class.pids_dir
|
22
|
-
puts "PidsFile dump : #{pids} => #{@file}"
|
23
|
-
File.write @file, pids.join($RS)
|
24
|
-
end
|
25
|
-
|
26
|
-
def read
|
27
|
-
return unless File.exist?(@file)
|
28
|
-
|
29
|
-
@pids = File.read(@file).split($RS).map(&:to_i)
|
30
|
-
puts "PidsFile read : #{@pids}"
|
31
|
-
@pids
|
32
|
-
end
|
33
|
-
|
34
|
-
def kill_each(pids = @pids)
|
35
|
-
Array(pids).each do |pid|
|
36
|
-
puts "PidsFile kill : #{pid}"
|
37
|
-
Process.kill('TERM', -Process.getpgid(pid))
|
38
|
-
rescue Errno::ESRCH
|
39
|
-
puts "Process #{pid} doesn't exist"
|
40
|
-
end
|
41
|
-
self
|
42
|
-
end
|
43
|
-
|
44
|
-
def delete
|
45
|
-
return unless File.exist?(@file)
|
46
|
-
|
47
|
-
File.delete @file
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
private_constant :PidsFile
|
52
|
-
end
|
53
|
-
end
|