-
Notifications
You must be signed in to change notification settings - Fork 37
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
Configurable worker environment variables #214
Merged
Merged
Conversation
This file contains 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
Signed-off-by: Link Dupont <[email protected]>
subpop
force-pushed
the
worker-env-var
branch
3 times, most recently
from
March 13, 2024 15:32
0747a4b
to
e167e4c
Compare
jirihnidek
requested changes
Mar 15, 2024
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.
Overall it is good. I have several comments, questions, suggestions and only few requests.
A worker may optionally install a configuration file into /etc/yggdrasil/workers. This configuration file, if present when a worker is started, is loaded. The 'env' field of the configuration file is parsed as a string slice. Elements of this slice must be in the form of a "VAR=VALUE" string, and are inserted into the worker process's environment before starting. It is forbidden to set PATH or any variable beginning with YGG_ in a worker's configuration file. Any variables by these names will be omitted when starting the worker process. HTTP proxy environment variables are automatically read from the yggd environment and are passed into the worker environment automatically. A sample echo worker config file has been added to demonstrate the new env field. Much of the code in exec.go was lifted into a new workers.go file. exec.go now containers lower level routines for starting and stopping processes. It has no awareness of the concept of a "worker". workers.go has higher-level functions that use the startProcess and stopProcess routines to start a worker process, create a PID file, wait for exit status, restart and backoff restart delays, etc. Signed-off-by: Link Dupont <[email protected]>
Clean up the worker validation logic slightly. Signed-off-by: Link Dupont <[email protected]>
jirihnidek
approved these changes
Mar 21, 2024
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.
LGTM
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 refactors the way processes are started, watched, killed, and restarted. The routines in
exec.go
were a mixture of higher-level worker process management (including restart delays, PID file management, etc.) and lower-level process start and kill routines. This PR moves the higher-level logic out ofexec.go
and into a file calledworker.go
. The routines inexec.go
are now purely lower-level routines that start and stop processes; they have no awareness of worker configuration or process restart management (startProcess
,stopProcess
,waitProcess
). The functions inworker.go
operate on aworkerConfig
data structure to start, stop and manage workers.A
workerConfig
structure is created by parsing an optional configuration file that must be defined in/etc/yggdrasil/workers
. This configuration file, if present when a worker is started, is loaded. The 'env' field of the configuration file is parsed as a string slice. Elements of this slice must be in the form of a "VAR=VALUE" string, and are inserted into the worker process's environment before starting. It is forbidden to set PATH or any variable beginning with YGG_ in a worker's configuration file. Any variables by these names will be omitted when starting the worker process.A worker's environment is automatically configured with a reasonable base PATH value (
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
) and inherits values from its parent for:http_proxy
,HTTP_PROXY
,HTTPS_PROXY
,ALL_PROXY
, andNO_PROXY
.