Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

daemon

> 编程语言
Open source

A daemon package for use with Go (golang) services

2.0K stars0 likes1 views
WebsiteGitHub

About

A daemon package for use with Go (golang) services

Go Daemon

A daemon package for use with Go (golang) services

Examples

Simplest example (just install self as daemon)

go
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)
}

Real example

…

Service config file

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

Example template(for linux systemv)

ini
[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.target

Cron example

See examples/cron/cron_job.go

Contributors (unsorted)

  • Sheile
  • Nguyen Trung Loi
  • Donny Prasetyobudi
  • Mark Berner
  • Fatih Kaya
  • Jannick Fahlbusch
  • TobyZXJ
  • Pichu Chen
  • Eric Halpern
  • Yota
  • Erkan Durmus
  • maxxant
  • 1for
  • okamura
  • 0X8C - Demired
  • Maximus
  • AlgorathDev
  • Alexis Camilleri
  • neverland4u
  • Rustam
  • King'ori Maina

All the contributors are welcome. If you would like to be the contributor please accept some rules.

  • The pull requests will be accepted only in develop branch
  • All modifications or additions should be tested
  • Sorry, We will not accept code with any dependency, only standard library

Thank you for your understanding!

License

MIT Public License

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Godaemongogolanglinux

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言