oye 0.1.8 → 0.1.9
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/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/oye/version.rb +1 -1
- data/lib/oye.rb +44 -24
- data/oye.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db235ec5368219133e4a2c3b13de51ca4fc021a584ba625828c1584da3b8c2c1
|
4
|
+
data.tar.gz: f0336786603d0f76352ed08230b514da02ab816fc0da825f4f5c5e308f9a8e04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c8c761835d0cd0398cb6c629be42843ea7266f8b641f9ecb4bbaa0de12d35bda0fa4e39bce0cdf451d694ed31981a0a16fc7d0c4e1005ed03cd934756b1750
|
7
|
+
data.tar.gz: 8883d0b11278ea7e5b8f898e887d910554b4da4c3fa46c8ee7506e64454c801cc00be98545cb4db757d43173cb48bf3a656eb30dd9a7b2dedf08515458a86aa5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,3 +13,6 @@ A continuous monitoring tool that does a few things:
|
|
13
13
|
[ ] why is the trap with `FileUtils.rm_f(oye_pidfile)` not removing the PID file
|
14
14
|
[ ] make a website for 'oye' where you provide better documentation. e.g.
|
15
15
|
- how to set up oye.yml
|
16
|
+
[ ] create a git brach called 'oye' and pull from that one instead of 'origin'.
|
17
|
+
[ ] suport remote branches via 'ssh'. e.g. you can use `Net::SSH` as i use in '~/.ruby/req'
|
18
|
+
[ ] support 'jekyll serve' for people that dont want to use a web server for jekyll
|
data/lib/oye/version.rb
CHANGED
data/lib/oye.rb
CHANGED
@@ -2,9 +2,9 @@ $LOAD_PATH.unshift __dir__
|
|
2
2
|
|
3
3
|
require "oye/version"
|
4
4
|
require 'fileutils'
|
5
|
-
require 'yaml'
|
6
5
|
require 'socket'
|
7
6
|
require 'timeout'
|
7
|
+
require 'yaml'
|
8
8
|
|
9
9
|
module Oye
|
10
10
|
class Error < StandardError; end
|
@@ -100,6 +100,7 @@ module Oye
|
|
100
100
|
trap(signal) do
|
101
101
|
stop_oye
|
102
102
|
FileUtils.rm_f(oye_pidfile)
|
103
|
+
log(oye_pidfile, status: :info, message: "Stopped oye")
|
103
104
|
exit
|
104
105
|
end
|
105
106
|
end
|
@@ -112,25 +113,16 @@ module Oye
|
|
112
113
|
|
113
114
|
pid = fork do
|
114
115
|
begin
|
115
|
-
# initialize apps if they are not running
|
116
|
-
# TODO i dont like this loop
|
117
116
|
@repos.values.flatten.each do |app|
|
118
117
|
app['clones'].each do |clone|
|
119
|
-
|
120
118
|
if !File.exists?(clone)
|
121
119
|
log(clone, status: :warn, message: "Could not find repo")
|
122
120
|
next
|
123
|
-
elsif !File.exists?(app_pid_dir(clone))
|
124
|
-
log(clone, status: :warn, message: "Could not find pids directory")
|
125
|
-
next
|
126
|
-
elsif File.exists?(app_pid_file(clone))
|
127
|
-
# if pid fle exists, the app should be running and there's no need to be initialize it
|
128
|
-
next
|
129
121
|
end
|
130
122
|
|
131
|
-
|
123
|
+
build_app(clone)
|
132
124
|
|
133
|
-
|
125
|
+
serve_app(clone)
|
134
126
|
end
|
135
127
|
end
|
136
128
|
|
@@ -150,9 +142,10 @@ module Oye
|
|
150
142
|
|
151
143
|
unless @repos[origin]['stat'] == File.stat(origin).ctime
|
152
144
|
@repos[origin]['stat'] = File.stat(origin).ctime
|
153
|
-
|
154
|
-
|
155
|
-
|
145
|
+
stop_app(clone) if File.exists?(app_pid_file(clone))
|
146
|
+
update_app(clone)
|
147
|
+
build_app(clone)
|
148
|
+
serve_app(clone)
|
156
149
|
end
|
157
150
|
end
|
158
151
|
end
|
@@ -181,31 +174,43 @@ module Oye
|
|
181
174
|
end
|
182
175
|
end
|
183
176
|
|
184
|
-
def
|
177
|
+
def build_app(dir)
|
185
178
|
Dir.chdir(dir) do
|
186
179
|
%x(bundle)
|
187
180
|
|
188
|
-
|
181
|
+
if rails_app?(dir)
|
182
|
+
%x(RAILS_ENV=#{@environment} rails db:migrate)
|
189
183
|
|
190
|
-
|
191
|
-
|
184
|
+
if @environment == 'production'
|
185
|
+
%x(RAILS_ENV=production rails assets:{clean,precompile})
|
186
|
+
end
|
187
|
+
elsif jekyll_app?(dir)
|
188
|
+
%x{jekyll build}
|
192
189
|
end
|
193
190
|
end
|
194
191
|
|
195
|
-
|
192
|
+
log(dir, status: :info, message: "Built app")
|
193
|
+
rescue => e
|
194
|
+
log(dir, status: :warn, message: "#{__method__.to_s} (#{e.message})")
|
195
|
+
end
|
196
196
|
|
197
|
-
|
197
|
+
def serve_app(dir)
|
198
|
+
if rails_app?(dir)
|
199
|
+
unicorn_options = @unicorn_default_options << " -c #{unicorn_file(dir)}"
|
198
200
|
|
199
|
-
|
201
|
+
%x{unicorn_rails #{unicorn_options}}
|
202
|
+
|
203
|
+
log(dir, status: :info, message: "Started app")
|
204
|
+
end
|
200
205
|
rescue => e
|
201
206
|
log(dir, status: :warn, message: "#{__method__.to_s} (#{e.message})")
|
202
207
|
end
|
203
208
|
|
204
|
-
def
|
209
|
+
def stop_app(dir)
|
205
210
|
Process.kill 'TERM', app_pid(dir)
|
206
211
|
end
|
207
212
|
|
208
|
-
def
|
213
|
+
def update_app(dir)
|
209
214
|
system("git -C #{dir} pull", [:out, :err] => File::NULL)
|
210
215
|
|
211
216
|
log(dir, status: :info, message: "Pulled from origin")
|
@@ -273,6 +278,21 @@ module Oye
|
|
273
278
|
|
274
279
|
private
|
275
280
|
|
281
|
+
# rails_app?, jekyll_app?
|
282
|
+
%w(rails jekyll).each do |app_type|
|
283
|
+
define_method("#{app_type}_app?") do |dir|
|
284
|
+
if File.exist?(gemfile(dir)) && File.read(gemfile(dir)).match?(/^\s*#{app_type}\b/)
|
285
|
+
true
|
286
|
+
else
|
287
|
+
false
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def gemfile(dir)
|
293
|
+
File.join(dir, "Gemfile.lock")
|
294
|
+
end
|
295
|
+
|
276
296
|
def port_open?(port)
|
277
297
|
begin
|
278
298
|
Timeout::timeout(1) do
|
data/oye.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sergioro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|