Documentation ¶
Overview ¶
Package exit encapsulates calls to os.Exit to control the production of process exit status codes.
Its goal is to ensure that all possible exit codes produced by the 'cockroach' process upon termination are documented. It achieves this by providing a type exit.Code and requiring that all possible values come from constructors in the package (see codes.go). A linter ensures that no direct call to os.Exit() can be present elsewhere.
Note that due to the limited range of unix exit codes, it is not possible to map all possible error situations inside a CockroachDB server to a unique exit code. This is why the main mechanism to explain the cause of a process termination must remain the logging subsystem.
The introduction of discrete exit codes here is thus meant to merely complement logging, in those cases where logging is unable to detail the reason why the process is terminating; for example:
- before logging is initialized (e.g. during command-line parsing) - when a logging operation fails.
For client commands, the situation is different: there are much fewer different exit situations, so we could envision discrete error codes for them. Additionally, different client commands can reuse the same numeric codes for different error situations, when they do not overlap.
This package accommodates this as follows:
exit codes common to all commands should be allocated incrementally starting from the last defined common error in codes.go.
exit codes specific to one command should be allocated downwards starting from 125.
Index ¶
- func WithCode(code Code)
- type Code
- func CommandLineFlagError() Code
- func DiskFull() Code
- func DoctorValidationFailed() Code
- func FatalError() Code
- func Interrupted() Code
- func Killed() Code
- func LoggingFileUnavailable() Code
- func LoggingNetCollectorUnavailable() Code
- func LoggingStderrUnavailable() Code
- func Success() Code
- func TimeoutAfterFatalError() Code
- func UnspecifiedError() Code
- func UnspecifiedGoPanic() Code
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
Code represents an exit code.
func CommandLineFlagError ¶
func CommandLineFlagError() Code
CommandLineFlagError (4) indicates there was an error in the command-line parameters.
func DiskFull ¶
func DiskFull() Code
DiskFull (10) indicates an emergency shutdown in response to a store's full disk.
func DoctorValidationFailed ¶
func DoctorValidationFailed() Code
DoctorValidationFailed indicates that the 'doctor' command has detected an inconsistency in the SQL metaschema.
func FatalError ¶
func FatalError() Code
FatalError (7) indicates that a logical error in the server caused an emergency shutdown.
func Interrupted ¶
func Interrupted() Code
Interrupted (3) indicates the server process was interrupted with Ctrl+C / SIGINT.
func Killed ¶
func Killed() Code
Killed (138) indicates the server process was terminated with SIGUSR1.
Orchestration code should handle this exit code the same way it would handle the process being killed via SIGKILL.
func LoggingFileUnavailable ¶
func LoggingFileUnavailable() Code
LoggingFileUnavailable (6) indicates that an error occurred during a logging operation to a file.
func LoggingNetCollectorUnavailable ¶
func LoggingNetCollectorUnavailable() Code
LoggingNetCollectorUnavailable (9) indicates that an error occurred during a logging operation to a network collector.
func LoggingStderrUnavailable ¶
func LoggingStderrUnavailable() Code
LoggingStderrUnavailable (5) indicates that an error occurred during a logging operation to the process' stderr stream.
func TimeoutAfterFatalError ¶
func TimeoutAfterFatalError() Code
TimeoutAfterFatalError (8) indicates that an emergency shutdown due to a fatal error did not occur properly due to some blockage in the logging system.
func UnspecifiedError ¶
func UnspecifiedError() Code
UnspecifiedError (1) indicates the process has terminated with an error condition. The specific cause of the error can be found in the logging output.
func UnspecifiedGoPanic ¶
func UnspecifiedGoPanic() Code
UnspecifiedGoPanic (2) indicates the process has terminated due to an uncaught Go panic or some other error in the Go runtime.
The reporting of this exit code likely indicates a programming error inside CockroachDB.
Conversely, this should not be used when implementing features.