Documentation ¶
Overview ¶
graceful package shutdown or reboot current process gracefully.
Copyright 2022 AndeyaLee. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func AddInherited(procFiles []*os.File, envs []*Env)
- func GraceSignal()
- func Reboot(timeout ...time.Duration)
- func SetLog(logger Logger)
- func SetShutdown(timeout time.Duration, firstSweepFunc, beforeExitingFunc func() error)
- func Shutdown(timeout ...time.Duration)
- type Env
- type Logger
- type LoggerWithFlusher
Constants ¶
const MinShutdownTimeout = 15 * time.Second
MinShutdownTimeout the default time-out period for the process shutdown.
Variables ¶
This section is empty.
Functions ¶
func AddInherited ¶
AddInherited adds the files and envs to be inherited by the new process. NOTE:
Only for reboot! Windows system are not supported!
func SetLog ¶
func SetLog(logger Logger)
SetLog resets logger. NOTE:
the logger is best to implement LoggerWithFlusher interface
func SetShutdown ¶
SetShutdown sets the function which is called after the process shutdown, and the time-out period for the process shutdown. If 0<=timeout<5s, automatically use 'MinShutdownTimeout'(5s). If timeout<0, indefinite period. 'firstSweepFunc' is first executed. 'beforeExitingFunc' is executed before process exiting.
Types ¶
type Logger ¶
type Logger interface { // Infof logs a message using INFO as log level. Infof(format string, v ...interface{}) // Errorf logs a message using ERROR as log level. Errorf(format string, v ...interface{}) }
Logger logger interface
type LoggerWithFlusher ¶
type LoggerWithFlusher interface { Logger // Flush writes any buffered log to the underlying io.Writer. Flush() error }
LoggerWithFlusher logger interface with flusher
Directories ¶
Path | Synopsis |
---|---|
Package inherit_net provides a family of Listen functions that either open a fresh connection or provide an inherited connection from when the process was started.
|
Package inherit_net provides a family of Listen functions that either open a fresh connection or provide an inherited connection from when the process was started. |