-
Notifications
You must be signed in to change notification settings - Fork 0
Initial work to switch from puma to unicorn #46
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
Open
WilliamMcCumstie
wants to merge
10
commits into
unicorn
Choose a base branch
from
dev/unicorn
base: unicorn
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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 is a long standing issue from puma days. Unicorn already logs, so the app doesn't have to
The worker needs to be shutdown after servicing the request
The request is now running as the correct user
e78b7ae to
bc44c93
Compare
1c2c4fd to
3c319ad
Compare
This required patching unicorn
| # NOTE: This will trigger the unicorn worker terminator upon finishing the request | ||
| before do | ||
| # Only worry about authenticated requests | ||
| next unless role == :user |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On review this looks wrong, leaving unauthenticated requests as root leaves me uneasy.
Probably best to switch to nobody.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR switches the web server from
pumatounicorn. Unicorn uses worker process to achieve concurrency as opposed to threads. Unicorn has the following features:master-workerarchitecture,mastermaintains a "worker pool" and will automatically restart dead workers,mastercan pre-load the application, allowing the workers to leverage copy-on-write, andworkerhandles a single request one at a time.flight-job-script-apiis an "unconventional" use case as it needs to run "flight-job" related code as a different user. This preventedflight-jobbeing used as a shared library withpuma. Instead, eachunicornworker now:after-replyhook to terminate itself.This allows the
workerto directly interact with the file-system as the correct user. As it has switched user, it can not be re-used for another request at this stage. This is a fairly uncommon use case forunicorn, so no inbuilt support is available. Instead the worker callsexit 0in therack.after_replyhook which then triggers themasterto restart it.This PR is focusing as a POC that
unicorncan be successfully used as a replacement forpuma. As such, it still uses a modified form of thefork-execintoflight-job.There are some minor speed benefits when reading the results files, as this can be done directly by the worker. However the majority of the benefits will be realised by re-working
flight-jobinto a shared library.Misc:
unicornis equivalent tomaster. Further work is going to be required beforeunicorncan become part of the mainline release cycle.useras the can get it fromENV.