bard-api 0.6.0 → 0.6.1
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/bard/api/app.rb +21 -7
- data/lib/bard/api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 563830ec8c572c92d9ccfe0baacef1e2e24746600e7a8d8508a3fe2819c6650e
|
|
4
|
+
data.tar.gz: f015d645e8d3bee75b1975b496ae53a93dc7e3bceeb2f21489a954e142862209
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f49e14b5cb6ab5b9a56c7b5f138d17c725ccdea8c995f9e9e811580ff0cb7801a65c77ce3ee7a6bc8e93cbc4dfb5748702c858873488e9551da8bc63356a518
|
|
7
|
+
data.tar.gz: ccfa6aec43edc4d1f30b23cb92b837e9535ef46f1e3b997791bcd0d0a25bb38b736682ef5a468d28652297b670cd0b80d6ebb8f30a8c9444bd446589d25b4290
|
data/lib/bard/api/app.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "rack"
|
|
4
4
|
require "json"
|
|
5
|
+
require "bundler"
|
|
5
6
|
require_relative "auth"
|
|
6
7
|
require "bard/backup"
|
|
7
8
|
|
|
@@ -25,17 +26,26 @@ module Bard
|
|
|
25
26
|
@deploy_runner ||= method(:spawn_detached_deploy)
|
|
26
27
|
end
|
|
27
28
|
|
|
29
|
+
# with_unbundled_env is essential: this worker runs under the app's bundle
|
|
30
|
+
# (RUBYOPT=-rbundler/setup, BUNDLE_GEMFILE). Inherited into the deploy, that makes every
|
|
31
|
+
# ruby command — bundle install included — crash at startup the moment git pull lands a
|
|
32
|
+
# lockfile with not-yet-installed gems. The deploy must start from a clean env.
|
|
28
33
|
def spawn_detached_deploy(command)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
Bundler.with_unbundled_env do
|
|
35
|
+
pid = Process.spawn(
|
|
36
|
+
"systemd-run", "--user", "--scope", "--collect", "--quiet", "bash", "-lc", command,
|
|
37
|
+
:in => "/dev/null", %i[out err] => ["log/bard-deploy.log", "a"],
|
|
38
|
+
)
|
|
39
|
+
Process.detach(pid)
|
|
40
|
+
end
|
|
34
41
|
end
|
|
35
42
|
end
|
|
36
43
|
|
|
37
44
|
DEPLOY_LOCK = "tmp/bard-deploy.lock"
|
|
38
|
-
|
|
45
|
+
DEPLOYED_SHA = "tmp/bard-deployed.sha"
|
|
46
|
+
# Record the deployed sha only after bin/setup fully succeeds — a bare `git pull` advances
|
|
47
|
+
# HEAD before the bundle/migrate/restart run, so HEAD alone would read as "done" too early.
|
|
48
|
+
DEPLOY_COMMAND = "flock -n #{DEPLOY_LOCK} -c 'git pull --ff-only origin master && bin/setup && git rev-parse HEAD > #{DEPLOYED_SHA}'"
|
|
39
49
|
|
|
40
50
|
def call(env)
|
|
41
51
|
request = Rack::Request.new(env)
|
|
@@ -130,8 +140,12 @@ module Bard
|
|
|
130
140
|
json_response(202, { status: "deploying", sha: sha })
|
|
131
141
|
end
|
|
132
142
|
|
|
143
|
+
# The last FULLY deployed sha (bin/setup succeeded), not merely where git HEAD points.
|
|
144
|
+
# Absent marker => nothing has completed yet, so it can never match the requested sha and
|
|
145
|
+
# the caller keeps polling until bin/setup writes it — or times out on a real failure.
|
|
133
146
|
def current_sha
|
|
134
|
-
|
|
147
|
+
return "" unless File.exist?(DEPLOYED_SHA)
|
|
148
|
+
File.read(DEPLOYED_SHA).chomp
|
|
135
149
|
end
|
|
136
150
|
|
|
137
151
|
def deploy_in_progress?
|
data/lib/bard/api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bard-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: jwt
|
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
132
|
version: '0'
|
|
133
133
|
requirements: []
|
|
134
|
-
rubygems_version:
|
|
134
|
+
rubygems_version: 4.0.6
|
|
135
135
|
specification_version: 4
|
|
136
136
|
summary: REST API for BARD-managed Rails projects
|
|
137
137
|
test_files: []
|