Documentation ¶
Index ¶
- Constants
- func CmdReload(socket net.Conn, log *logger.Log, arg bool)
- func CmdRestart(socket net.Conn, log *logger.Log, arg bool)
- func CmdSetLogPrintLevel(socket net.Conn, log *logger.Log, arg string)
- func CmdSetLogRecordLevel(socket net.Conn, log *logger.Log, arg string)
- func CmdStatus(socket net.Conn, log *logger.Log, arg bool)
- func CmdStop(socket net.Conn, log *logger.Log, arg bool)
- func DaemonMain()
- func StartForkedDaemon(log *logger.Log)
- type DaemonCommand
- type DaemonCommandArg
- type DaemonCommandCallback
- func GetLogPrintCallback() DaemonCommandCallback
- func GetLogRecordCallback() DaemonCommandCallback
- func GetReloadCallback(signalChan chan os.Signal) DaemonCommandCallback
- func GetRestartCallback(serverCommandChan chan server.ServerThreadCommand) DaemonCommandCallback
- func GetStatusCallback(handler *server.Handler) DaemonCommandCallback
- func GetStopCallback(signalChan chan os.Signal) DaemonCommandCallback
- type DaemonCommandSuccess
- type DaemonListener
- type ReloadSignal
- type StopSignal
- type WebbyStatus
Constants ¶
const ( // Restarts the HTTP server and rescans directories. Useful when edits have // been made to the website contents. Should ignore the passed in argument. Restart = "restart" // Reloads the configuration file and then restarts. Reload = "reload" // Stops the current daemon. Stop = "stop" // Gets webby's current status, status needs to be representable in the single // byte returned to the client after a daemon command. Status = "status" // Like the Daemon variant this variant should not have a callback, and is // intended to generate a default configuration file. GenConfig = "gen-config" // Sets the log level for recording logs to file. Should interperet its // argument to be the desired log level. LogRecord = "log-record" // Sets the log level for printing to standard out. As a daemonized program // this will be what shows up when checking the output of `# systemctl status // webby`. Should interperet its argument to be the desired log level. LogPrint = "log-print" )
const CONFIG_PATH = "/etc/webby/config.json"
const SocketPath = "/run/webby.sock"
The path of the Unix Domain Socket created by webby for accepting commands.
Variables ¶
This section is empty.
Functions ¶
func CmdReload ¶
Sends the reload command to the daemon through the provided socket.
This function is intended as the end of execution for the command it represents and will therefore perform I/O operations, output to the user, and indicate errors only though these means.
func CmdRestart ¶
Sends the restart command to the daemon through the provided socket.
This function is intended as the end of execution for the command it represents and will therefore perform I/O operations, output to the user, and indicate errors only though these means.
func CmdSetLogPrintLevel ¶
Sends the set print log level command to the daemon, using the given command line argument, through the provided socket.
This function is intended as the end of execution for the command it represents and will therefore perform I/O operations, output to the user, and indicate errors only though these means.
func CmdSetLogRecordLevel ¶
Sends a command, using the given command line argument, to the daemon using the provided socket.
This function is intended as the end of execution for the command it represents and will therefore perform I/O operations, output to the user, and indicate errors only though these means.
func CmdStop ¶
Sends the stop command to the daemon through the provided socket.
This function is intended as the end of execution for the command it represents and will therefore perform I/O operations, output to the user, and indicate errors only though these means.
func StartForkedDaemon ¶
Starts a daemon process and forks it.
Types ¶
type DaemonCommand ¶
type DaemonCommand string
Represents possible commands from client connections.
type DaemonCommandArg ¶
type DaemonCommandArg uint8
The only argument that will be given to the callbacks for deamon commands. Each callback may interperet this differently, for example, the restart command ignores its argument, but log level commands will interperet this to be a log level.
type DaemonCommandCallback ¶
type DaemonCommandCallback func(DaemonCommandArg) DaemonCommandSuccess
Type alias for the function signature of a daemon command callback.
func GetLogPrintCallback ¶
func GetLogPrintCallback() DaemonCommandCallback
Returns a function, that when called, will modify the given log's recording log level to match its parameters.
func GetLogRecordCallback ¶
func GetLogRecordCallback() DaemonCommandCallback
Returns a function, that when called, will modify the given log's printing log level to match its parameters.
func GetReloadCallback ¶
func GetReloadCallback(signalChan chan os.Signal) DaemonCommandCallback
Returns a function that will send a `ReloadSignal` though the given channel when called.
func GetRestartCallback ¶
func GetRestartCallback(serverCommandChan chan server.ServerThreadCommand) DaemonCommandCallback
Returns a function that will sent the `server.Restart` constant through the given channel when called.
func GetStatusCallback ¶
func GetStatusCallback(handler *server.Handler) DaemonCommandCallback
Returns a function that simply returns `Success` when called. If callbacks are being called and the daemon can give the success message to a connection then we consider this to be "ok" on webby's side.
func GetStopCallback ¶
func GetStopCallback(signalChan chan os.Signal) DaemonCommandCallback
Returns a function that will send a `StopSignal` through the given channel when called.
type DaemonCommandSuccess ¶
type DaemonCommandSuccess uint8
The success/failure of a daemon command. This will appear as a single byte response to any client commands indicating the success or failure of a command.
const ( // The daemon command completed successfuly. Success DaemonCommandSuccess = iota // The daemon command failed. Failure )
type DaemonListener ¶
type DaemonListener struct {
// contains filtered or unexported fields
}
func NewDaemonListener ¶
func NewDaemonListener(callbacks map[DaemonCommand]DaemonCommandCallback) (DaemonListener, error)
Creates a new Unix Domain Socket and returns a pointer to a listener for application commands and requests on that socket. When the listener is started all commands will be executed according to the given callbacks.
func (*DaemonListener) Close ¶
func (daemon *DaemonListener) Close() error
Closes the backing Unix Domain Socket. After calling this function no other calls should be made to this struct's functions.
func (*DaemonListener) Listen ¶
func (daemon *DaemonListener) Listen() error
Starts listening for connections on the Unix Domain Socket. Each connection will be able to run one command and will be responded to with a `DaemonCommandSuccess` value.
type ReloadSignal ¶
type ReloadSignal struct{}
Represents a signal originating at a daemon command and sent through a channel by the reload callback.
func (ReloadSignal) Signal ¶
func (r ReloadSignal) Signal()
func (ReloadSignal) String ¶
func (r ReloadSignal) String() string
type StopSignal ¶
type StopSignal struct{}
Represent a signal originating at a daemmon command and sent through a channel by the stop callback
func (StopSignal) Signal ¶
func (r StopSignal) Signal()
func (StopSignal) String ¶
func (r StopSignal) String() string
type WebbyStatus ¶
type WebbyStatus uint8
Represents the status returned by the status callback
const ( Ok WebbyStatus = WebbyStatus(Success) // All gets gave 200 HttpNon2xx WebbyStatus = WebbyStatus(Failure) | ((iota + 1) << 1) // Not every get gave 200 HttpPartialFail // Some gets gave code >= 400 HttpFail // All gets gave code >= 400 )