Documentation ¶
Overview ¶
Example ¶
package main import ( "context" "fmt" "github.com/holyhope/god" _ "github.com/holyhope/god/launchd" ) func main() { unit, err := god.New( context.Background(), god.Opts(). WithName("com.github.holyhope.test.god_example"). WithProgram("/bin/bash"). WithArguments("-c", `echo "Hello, world!"`). WithScope(god.ScopeUser), ) if err != nil { panic(err) } // Install the unit to the system _ = unit.Create(context.Background()) fmt.Println("Unit installed") // Enable the unit _ = unit.Enable(context.Background()) fmt.Println("Unit enabled") // Delete the unit to the system _ = unit.Delete(context.Background()) fmt.Println("Unit uninstalled") }
Output: Unit installed Unit enabled Unit uninstalled
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewMissingOptionError ¶
Types ¶
type DarwinLimitLoadToSessionType ¶
type DarwinLimitLoadToSessionType uint8
const ( DarwinLimitLoadToSessionAqua DarwinLimitLoadToSessionType = iota DarwinLimitLoadToSessionStandardIO DarwinLimitLoadToSessionBackground DarwinLimitLoadToSessionLoginWindow )
func (DarwinLimitLoadToSessionType) String ¶
func (i DarwinLimitLoadToSessionType) String() string
type DarwinOptions ¶
type DarwinOptions interface {
// contains filtered or unexported methods
}
type InvalidOptionError ¶
type InvalidOptionError struct { Key string Value interface{} }
func (*InvalidOptionError) Error ¶
func (err *InvalidOptionError) Error() string
func (*InvalidOptionError) Is ¶
func (err *InvalidOptionError) Is(err2 error) bool
type MissingOptionError ¶
type MissingOptionError InvalidOptionError
func (*MissingOptionError) Error ¶
func (err *MissingOptionError) Error() string
type Options ¶
type Options interface { DarwinOptions // contains filtered or unexported methods }
Example ¶
package main import ( "context" "github.com/holyhope/god" _ "github.com/holyhope/god/launchd" ) func main() { u, _ := god.New( context.Background(), god.Opts(). WithName("my-unit"). WithScope(god.ScopeUser), ) _ = u.Create(context.Background()) _ = u.Enable(context.Background()) // Cleanup filesystem _ = u.Delete(context.Background()) }
Output:
type Unit ¶
type Unit interface { // Create the unit to the system. Create(ctx context.Context) error // Enable the unit. Enable(ctx context.Context) error // Delete the unit from the system. Delete(ctx context.Context) error // Disable the unit. Disable(ctx context.Context) error // Status the status of the unit. Status(ctx context.Context) (UnitStatus, error) }
Unit represents single service managed by either systemd or launchd.
type UnitStatus ¶
type UnitStatus interface { // Exists returns true if the unit is on the filesystem. Exists(ctx context.Context) bool // IsEnabled returns true if the unit is enable. IsEnabled(ctx context.Context) bool }
func NewUnitStatus ¶
func NewUnitStatus(exists bool, enabled bool) UnitStatus
Source Files ¶
- errors.go
- god.go
- god_linux.go
- interfaces.go
- options.go
- options_arguments.go
- options_darwin_limitloadtosession.go
- options_darwin_limitloadtosession_stringer.go
- options_description.go
- options_envvars.go
- options_groupowner.go
- options_interval.go
- options_name.go
- options_program.go
- options_runatload.go
- options_scope.go
- options_scope_stringer.go
- options_startlimitinterval.go
- options_state.go
- options_state_stringer.go
- options_stderr.go
- options_stdout.go
- options_userowner.go
- options_watchingfiles.go
- options_workingdirectory.go
- unit_status.go
Click to show internal directories.
Click to hide internal directories.