Skip to content

lemenkov/systemd.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Socket Activation for SystemD

Installation

$ go get github.com/lemenkov/systemd.go # ignore the following error
stat github.com/lemenkov/systemd.go: no such file or directory
$

Usage

import "github.com/lemenkov/systemd.go"

func main() {
  var listener net.Listener

  sockets, err = systemd.ListenFds()
  if sockets == nil {
    listener, err = net.ListenUnix("unix", "/tmp/servicename.socket")
  } else {
    listener, err = net.ListenFile(sockets[0])
  }

  if err != nil {
    log.Fatalf("error setting up socket: %s", err)
  }

  // TODO: Set up your HTTP handlers here.

  http.Serve(listener, http.DefaultServeMux)
}

About

systemd socket activation meets golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages