bard-api 0.6.3 → 0.6.4
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 +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d007a479b7de5d4e3508479577848275fc7a9cdf50b73df55767eb09d1318f6c
|
|
4
|
+
data.tar.gz: 3f5580a11475da6bfe7676027a4e571599731f325acc92a19f8afff134babcb5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a6e68bfb8c288f7c8dd4a1027bd44b511a30917f1e60cdbee3f5df7d05cbab6ca566e3eb94a7affd433924c15b2b808e4a95ebbbd88e1eef8d42335b7e396e19
|
|
7
|
+
data.tar.gz: 40d72eaa6bc942c5aa16f1afc2d325012afd18d2effb4cc085a016b28d29da0d1721e0da0c8034af9b9684311dd8f7dd1f34ce685b822b3ac97381808a6cb7e0
|
data/lib/bard/api/app.rb
CHANGED
|
@@ -26,22 +26,32 @@ module Bard
|
|
|
26
26
|
@deploy_runner ||= method(:spawn_detached_deploy)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
#
|
|
29
|
+
# The deploy must start from a clean env: this worker runs under the app's bundle
|
|
30
30
|
# (RUBYOPT=-rbundler/setup, BUNDLE_GEMFILE). Inherited into the deploy, that makes every
|
|
31
|
-
# ruby command — bundle install included — crash at startup the moment
|
|
32
|
-
# lockfile with not-yet-installed gems.
|
|
31
|
+
# ruby command — bin/setup and bundle install included — crash at startup the moment
|
|
32
|
+
# git pull lands a lockfile with not-yet-installed gems.
|
|
33
33
|
def spawn_detached_deploy(command)
|
|
34
34
|
Bundler.with_unbundled_env do
|
|
35
|
-
# A Passenger web worker is spawned without a login session, so it has no XDG_RUNTIME_DIR;
|
|
36
|
-
# systemd-run --user needs it to find the (linger-backed) user bus at $XDG_RUNTIME_DIR/bus.
|
|
37
35
|
pid = Process.spawn(
|
|
38
|
-
|
|
36
|
+
deploy_env,
|
|
39
37
|
"systemd-run", "--user", "--scope", "--collect", "--quiet", "bash", "-lc", command,
|
|
40
38
|
:in => "/dev/null", %i[out err] => ["log/bard-deploy.log", "a"],
|
|
41
39
|
)
|
|
42
40
|
Process.detach(pid)
|
|
43
41
|
end
|
|
44
42
|
end
|
|
43
|
+
|
|
44
|
+
# with_unbundled_env alone isn't enough: it restores Bundler::ORIGINAL_ENV, and under
|
|
45
|
+
# Passenger RUBYOPT=-rbundler/setup is injected before the app boots, so it's part of
|
|
46
|
+
# ORIGINAL_ENV and survives the scrub (took brianporter.com down on 2026-07-15). Strip
|
|
47
|
+
# the bundler vars explicitly — nil values remove them from the spawned env.
|
|
48
|
+
# XDG_RUNTIME_DIR: a Passenger web worker is spawned without a login session, so it's
|
|
49
|
+
# unset; systemd-run --user needs it to find the (linger-backed) user bus.
|
|
50
|
+
def deploy_env
|
|
51
|
+
bundler_vars = ENV.keys.grep(/\A(BUNDLE_|BUNDLER_)/) + %w[RUBYOPT RUBYLIB]
|
|
52
|
+
bundler_vars.to_h { |key| [key, nil] }
|
|
53
|
+
.merge("XDG_RUNTIME_DIR" => "/run/user/#{Process.uid}")
|
|
54
|
+
end
|
|
45
55
|
end
|
|
46
56
|
|
|
47
57
|
DEPLOY_LOCK = "tmp/bard-deploy.lock"
|
|
@@ -56,11 +66,15 @@ module Bard
|
|
|
56
66
|
# HEAD before the bundle/migrate/restart run, so HEAD alone would read as "done" too early.
|
|
57
67
|
# On any failure, stamp the attempted sha so we don't re-spawn (and restart Puma) on every
|
|
58
68
|
# poll; the marker is written inside the flock, so it's on disk before the lock releases.
|
|
69
|
+
# Then roll the tree back to the pre-pull sha: code sitting ahead of its installed gems is
|
|
70
|
+
# a time bomb — the next app-process respawn (e.g. an nginx reload) can't boot and the
|
|
71
|
+
# site 500s until someone intervenes. Better to keep running the old code.
|
|
59
72
|
DEPLOY_COMMAND =
|
|
60
73
|
"flock -n #{DEPLOY_LOCK} -c '" \
|
|
61
74
|
"rm -f #{FAILED_SHA}; " \
|
|
75
|
+
"before=$(git rev-parse HEAD); " \
|
|
62
76
|
"git pull --ff-only origin master && bin/setup && git rev-parse HEAD > #{DEPLOYED_SHA} " \
|
|
63
|
-
"|| git rev-parse origin/master > #{FAILED_SHA}'"
|
|
77
|
+
"|| { git rev-parse origin/master > #{FAILED_SHA}; git reset --hard \"$before\"; }'"
|
|
64
78
|
|
|
65
79
|
def call(env)
|
|
66
80
|
request = Rack::Request.new(env)
|
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-07-
|
|
10
|
+
date: 2026-07-15 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: jwt
|