Repository navigation
Run background jobs in a dedicated worker container #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
af10eac
Run background jobs in a dedicated worker container
phantomic12 88a7193
Keep HLS cleanup in the web container and document the worker service
phantomic12 9ca0960
Merge remote-tracking branch 'upstream/main' into deployment-fixes
phantomic12 91c681e
Run the web HLS cleanup in both job layouts and detect Puma
phantomic12 13e8b8c
Merge remote-tracking branch 'upstream/main' into deployment-fixes
phantomic12 dfaa6ef
Start the web HLS cleanup from Puma's boot hook
phantomic12 a896c23
Read SOLID_QUEUE_IN_PUMA without ActiveSupport in the Puma config
phantomic12 0ce216a
Use Puma's after_booted hook instead of the deprecated on_booted
phantomic12 31bb7dd
Start the HLS cleanup only from the Puma hook
phantomic12 28a6fe7
Drop the trailing blank line the initializer left behind
phantomic12 fb30835
Keep a single TLS section in the example environment
phantomic12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # HLS sessions are created, transcoded and served by the web container: their | ||
| # rows carry PIDs and tmp/hls paths that exist nowhere else. Running the | ||
| # cleanup from the worker would delete the rows while leaving every segment | ||
| # on the web disk, and could signal an unrelated process that reused the PID. | ||
| # | ||
| # With SOLID_QUEUE_IN_PUMA the scheduler already lives in Puma, so the thread | ||
| # below only starts when a separate worker owns job execution. | ||
| if Rails.env.production? && | ||
| ActiveModel::Type::Boolean.new.cast(ENV["SOLID_QUEUE_IN_PUMA"].presence || "false") != true && | ||
|
vitobotta marked this conversation as resolved.
Resolved
|
||
| ENV["HLS_CLEANUP_IN_WEB"] != "false" | ||
| Rails.application.config.after_initialize do | ||
| next unless defined?(Rails::Server) | ||
|
vitobotta marked this conversation as resolved.
Resolved
|
||
|
|
||
| Rails.logger.info("[HlsSessionCleanup] starting web-side HLS cleanup loop") | ||
| Thread.new do | ||
| loop do | ||
| begin | ||
| Rails.application.executor.wrap { HlsSessionManager.cleanup_expired } | ||
| rescue StandardError => e | ||
| Rails.logger.warn("[HlsSessionCleanup] #{e.class}: #{e.message}") | ||
| end | ||
| sleep 300 | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.