All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m35s
Test / Sandbox (race detector) (push) Successful in 2m30s
Test / Hpkg (push) Successful in 4m14s
Test / Hakurei (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 4m50s
Test / Flake checks (push) Successful in 1m35s
This is slightly counterintuitive, but it turned out well under this framework since the daemon backs its target file. Signed-off-by: Ophestra <cat@gensokyo.uk>
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package hst
|
|
|
|
import (
|
|
"encoding/gob"
|
|
"strconv"
|
|
|
|
"hakurei.app/container/check"
|
|
)
|
|
|
|
func init() { gob.Register(new(FSDaemon)) }
|
|
|
|
// FilesystemDaemon is the type string of a daemon.
|
|
const FilesystemDaemon = "daemon"
|
|
|
|
// FSDaemon represents a daemon to be started in the container.
|
|
type FSDaemon struct {
|
|
// Pathname indicating readiness of daemon.
|
|
Target *check.Absolute `json:"dst"`
|
|
// Absolute pathname to daemon executable file.
|
|
Exec *check.Absolute `json:"path"`
|
|
// Arguments (excl. first) passed to daemon.
|
|
Args []string `json:"args"`
|
|
}
|
|
|
|
func (d *FSDaemon) Valid() bool { return d != nil && d.Target != nil && d.Exec != nil }
|
|
|
|
func (d *FSDaemon) Path() *check.Absolute {
|
|
if !d.Valid() {
|
|
return nil
|
|
}
|
|
return d.Target
|
|
}
|
|
|
|
func (d *FSDaemon) Host() []*check.Absolute { return nil }
|
|
|
|
func (d *FSDaemon) Apply(z *ApplyState) {
|
|
if !d.Valid() {
|
|
return
|
|
}
|
|
z.Daemon(d.Target, d.Exec, d.Args...)
|
|
}
|
|
|
|
func (d *FSDaemon) String() string {
|
|
if !d.Valid() {
|
|
return "<invalid>"
|
|
}
|
|
|
|
return "daemon providing " + strconv.Quote(d.Target.String())
|
|
}
|