File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- DEPLOY_TIME = Time . now . to_i
1+ # frozen_string_literal: true
2+
3+ # Identifies the running release. It MUST be identical across every process of a
4+ # single deploy (web, worker, etc.) and change when new code ships — it's what
5+ # tells long-lived realtime display pages to reload after a deploy.
6+ #
7+ # It must NOT be derived from per-process boot time: the web and worker
8+ # processes boot at different seconds, so a `Time.now` value would differ
9+ # between the process that renders the display page and the worker process that
10+ # runs DeviceBroadcaster. Every cross-process refresh broadcast would then look
11+ # like a brand-new deploy and force a full-page reload (an e-ink flash) every
12+ # minute.
13+ #
14+ # Prefer an explicit/platform-provided release id; otherwise fall back to a
15+ # digest of the compiled assets (built once per deploy, identical across all
16+ # dynos), and finally to boot time for local single-process runs.
17+ DEPLOY_TIME =
18+ ENV [ "DEPLOY_VERSION" ] . presence ||
19+ ENV [ "HEROKU_RELEASE_VERSION" ] . presence ||
20+ ENV [ "HEROKU_SLUG_COMMIT" ] . presence ||
21+ begin
22+ builds = Dir [ Rails . root . join ( "app/assets/builds/*" ) ] . sort
23+ builds . any? ? Digest ::MD5 . hexdigest ( builds . map { |f | File . read ( f ) } . join ) : Time . now . to_i
24+ rescue
25+ Time . now . to_i
26+ end
You can’t perform that action at this time.
0 commit comments