-
Notifications
You must be signed in to change notification settings - Fork 373
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
Introduce supervisor.procHandle interface #5137
Conversation
Signed-off-by: Tom Wieczorek <[email protected]>
Signed-off-by: Tom Wieczorek <[email protected]>
Add the cmdline and environ functions to it. Signed-off-by: Tom Wieczorek <[email protected]>
This encapsulates the kill syscall. Signed-off-by: Tom Wieczorek <[email protected]>
pkg/supervisor/supervisor_unix.go
Outdated
// killPid tries to gracefully terminate a PID. If it's still running after | ||
// s.TimeoutStop the process will be terminated forcibly. | ||
func (s *Supervisor) killPid(ph procHandle) error { |
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.
I think it would make more sense to avoid the term PID entirely in this function because the interface is an abstraction that doesn't include the PID itself, even though it's there underneath.
// killPid tries to gracefully terminate a PID. If it's still running after | |
// s.TimeoutStop the process will be terminated forcibly. | |
func (s *Supervisor) killPid(ph procHandle) error { | |
// killProcess tries to gracefully terminate a Process. If it's still running after | |
// s.TimeoutStop the process will be terminated forcibly. | |
func (s *Supervisor) killProcess(ph procHandle) error { |
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.
Alright, done.
This encapsulates all of the OS-specific code for interacting with processes identified by PID files. Signed-off-by: Tom Wieczorek <[email protected]>
This will be the new factory function for OS-specific process interaction. Signed-off-by: Tom Wieczorek <[email protected]>
Move the now OS-agnostic Supervisor methods maybeKillPidFile, shouldKillProcess and killPid from the UNIX-specific file into the general one. Signed-off-by: Tom Wieczorek <[email protected]>
The supervisor code is now completely OS independent. It uses the procHandle interface to abstract away any OS specifics. Rename the old OS-specific supervisor files to prochandle, since that's what they contain now. Signed-off-by: Tom Wieczorek <[email protected]>
1186969
to
ceaa0f9
Compare
Description
This encapsulates all OS-specific code for interacting with processes identified by PID files. This allows OS agnostic code parts to be shared across OSes, and it opens a way to more easily add Windows support in the future.
The OS specific features are:
The code has been refactored to first introduce freestanding functions for command line and environment inspection, then add a new type to which these functions have been moved and which is used by the OS agnostic methods. Finally, the methods have been moved out of platform-specific files, and the platform-specific files have been renamed to reflect that they belong to the new
procHandle
abstraction.Type of change
How Has This Been Tested?
Checklist: