A daemon package for use with Go (golang) services
A daemon package for use with Go (golang) services
package main
import (
"fmt"
"log"
"github.com/takama/daemon"
)
func main() {
service, err := daemon.New("name", "description", daemon.SystemDaemon)
if err != nil {
log.Fatal("Error: ", err)
}
status, err := service.Install()
if err != nil {
log.Fatal(status, "\nError: ", err)
}
fmt.Println(status)
}…Optionally, service config file can be retrieved or updated by calling
GetTemplate() string and SetTemplate(string) methods(except MS
Windows). Template will be a default Go Template("text/template").
If SetTemplate is not called, default template content will be used
while creating service.
| Variable | Description |
|---|---|
| Description | Description for service |
| Dependencies | Service dependencies |
| Name | Service name |
| Path | Path of service executable |
| Args | Arguments for service executable |
[Unit]
Description={{.Description}}
Requires={{.Dependencies}}
After={{.Dependencies}}
[Service]
PIDFile=/var/run/{{.Name}}.pid
ExecStartPre=/bin/rm -f /var/run/{{.Name}}.pid
ExecStart={{.Path}} {{.Args}}
Restart=on-failure
[Install]
WantedBy=multi-user.targetSee examples/cron/cron_job.go
All the contributors are welcome. If you would like to be the contributor please accept some rules.
develop branchThank you for your understanding!
No open issues yet, or sync has not completed.