-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: Supervisor supports automatic restart configuration. #8413
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,13 +23,14 @@ type HostToolConfig struct { | |
| } | ||
|
|
||
| type SupervisorProcessConfig struct { | ||
| Name string `json:"name"` | ||
| Command string `json:"command"` | ||
| User string `json:"user"` | ||
| Dir string `json:"dir"` | ||
| Numprocs string `json:"numprocs"` | ||
| Msg string `json:"msg"` | ||
| Status []ProcessStatus `json:"status"` | ||
| Name string `json:"name"` | ||
| Command string `json:"command"` | ||
| User string `json:"user"` | ||
| Dir string `json:"dir"` | ||
| Numprocs string `json:"numprocs"` | ||
| Msg string `json:"msg"` | ||
| Status []ProcessStatus `json:"status"` | ||
| AutoRestart string `json:"autoRestart"` | ||
| } | ||
|
|
||
| type ProcessStatus struct { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code snippet is for Irregularity: The new field Potential issues: Without further context on whether this new field is necessary or how it fits into the existing system, there might be confusion about its purpose and potential integration bugs with other parts of the application. Optimization Suggestions:
Overall, while having no immediate technical issue per se, updating documentation and ensuring consistent behavior could improve maintainability and clarity of the codebase. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,7 +322,7 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c | |
| } | ||
| _, _ = section.NewKey("command", strings.TrimSpace(req.Command)) | ||
| _, _ = section.NewKey("directory", req.Dir) | ||
| _, _ = section.NewKey("autorestart", "true") | ||
| _, _ = section.NewKey("autorestart", req.AutoRestart) | ||
| _, _ = section.NewKey("startsecs", "3") | ||
| _, _ = section.NewKey("stdout_logfile", outLog) | ||
| _, _ = section.NewKey("stderr_logfile", errLog) | ||
|
|
@@ -358,6 +358,8 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c | |
| userKey.SetValue(req.User) | ||
| numprocsKey := section.Key("numprocs") | ||
| numprocsKey.SetValue(req.Numprocs) | ||
| autoRestart := section.Key("autorestart") | ||
| autoRestart.SetValue(req.AutoRestart) | ||
|
|
||
| if err = configFile.SaveTo(iniPath); err != nil { | ||
| return err | ||
|
|
@@ -424,6 +426,9 @@ func handleProcessConfig(configDir, containerName string) ([]response.Supervisor | |
| if numprocs, _ := section.GetKey("numprocs"); numprocs != nil { | ||
| config.Numprocs = numprocs.Value() | ||
| } | ||
| if autoRestart, _ := section.GetKey("autorestart"); autoRestart != nil { | ||
| config.AutoRestart = autoRestart.Value() | ||
| } | ||
| _ = getProcessStatus(&config, containerName) | ||
| result = append(result, config) | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The provided code has no significant inaccuracies or issues. The |
||
|
|
||
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.
The provided JSON structure seems to be part of a configuration file used by Supervisord, an process control system for Unix-like operating systems. The main concern is that the
SupervisorProcessConfigcontains two fields with different names but similar functionality:NumprocsAutoRestartIt's not clear why these would have separate names (
"numprocs"vs"autoRestart") when they seem to represent the same concept: specifying a number of processes to start and whether to automatically restart them in case of failure.Here are some suggestions for improvement:
Consistency: If
NumprocsandAutoRestartshould actually differ (e.g., if one controls automatic restarting while the other specifies the number of instances) then rename them appropriately based on their actual functions or usage within the Supervisor context.Documentation: Ensure that this difference between
NumprocsandAutoRestartis clearly documented so it’s understood what each field does.Default Values: Consider setting default values for both fields to make configuration more flexible depending on specific use cases.
Field Uniqueness: Verify that no other code relies on these field names specifically to avoid potential bugs or unintended behaviors due to naming inconsistencies.
If you want to align the fields and provide clarity about how they relate to auto-restarting behavior, here's a revised version:
This revision maintains consistency while providing additional information through better naming and documentation practices.