• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created about 11 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Utility to "daemonize" Go programs

Go daemon

Go daemon (or just god) is a utility to "daemonize" Go programs that originally only run in foreground and write logs to the console.

Go daemon can turn these programs into daemons by managing essential aspects of their execution. The process of making a program become a daemon has very peculiar steps and can be done outside the code. This is what god is for.

It executes a program for you doing things that daemons do: switch to another user and group, switch the directory of execution, detach from the terminal and create a pid file. While the program runs, god consumes its output (stdout and stderr) and write to a log file using minimum system resources.

It also handles all signals (SIGINT, SIGTERM, etc) and forward them to the program being managed. On SIGHUP, god recycles its log file making it easy to integrate with logrotate. If SIGHUP is not supported by your program, god can handle the signal itself and not forward it, making your program immune to hangups.

Go daemon is inspired by twistd, but primarily for running servers written in the Go Programming Language that don't (or just can't) care about daemonizing. However, it can also be used for running php, python and any other type of long lived programs that need to be daemonized.

A typical command line looks like this:

god --nohup --logfile foo.log --pidfile foo.pid --user nobody --group nobody --rundir /opt/foo -- ./foobar --foobar-opts

Why?

Like if there's not enough options out there: upstart, systemd, launchd, daemontools, supervisord, runit, you name it. There's also utilities like apache's logger, etc.

Go daemon aims at being as simple as possible in regards to deployment and usage, and to run with minimum resources. It doesn't supervise the program, just run it as a daemon and takes care of its console output. It mixes well with upstart and logrotate, for example.

Go daemon is not needed on systems with systemd.

Building

Go daemon is written in C and needs to be compiled. Debian and Ubuntu can install the compiler and tools with the following command:

apt-get install build-essential

Then build and install it:

make
make install

The god command line tool should be ready to use.

Binary packages

Go daemon can be packaged for both debian and rpm based systems and has been tested on Ubuntu, CentOS and RHEL.

See the releases page for pre-compiled packages.

More Repositories

1

freegeoip

IP geolocation web server
Go
4,931
star
2

wsdl2go

Command line tool to generate Go code from WSDL for SOAP XML services
Go
449
star
3

go-diameter

Diameter stack and Base Protocol (RFC 6733) for the Go programming language
Go
244
star
4

go-smpp

SMPP 3.4 Protocol for the Go programming language
Go
218
star
5

protoc-gen-cobra

Cobra command line tool generator for gRPC clients
Go
189
star
6

go-eventsocket

FreeSWITCH Event Socket library for the Go programming language.
Go
125
star
7

cat-o-licious

Cat game written in Go
Go
104
star
8

eventsocket

Twisted protocol for the FreeSWITCH's Event Socket
Python
54
star
9

go-web

Utilities for http servers written in Go
Go
52
star
10

sms-api-server

HTTP API to send SMS via SMPP
Go
47
star
11

go-redis

Redis client library for Go
Go
45
star
12

txtraceroute

An asynchronous, pure python, traceroute with geolocation information
Python
44
star
13

twisted-twitter-stream

Twitter Stream API for Twisted
Python
43
star
14

jsonschema2go

Code generator for JSON schema
Go
38
star
15

ffmpeg-arm

Docker image with ffmpeg for ARM (Raspberry Pi)
37
star
16

nitgen-bsp

Python extension for Nitgen fingerprint recognition devices
C
22
star
17

mustash

recognize people's face and put a mustache on it
Python
15
star
18

defacer

meow
Go
12
star
19

go-swagger-ui

Go HTTP handler for serving swagger-ui
Go
10
star
20

niosted

Experimental reactor on top of Java NIO
Python
8
star
21

gocp

Go Concurrency Primitives
Go
7
star
22

dotfiles

my set of configuration files
Shell
5
star
23

go-talks

A collection of my Go talks
Go
5
star
24

txdbapi

Experimental ORM for Twisted based on Twistar
Python
4
star
25

pyqrcode

QRcode encoder and decoder for python
Java
4
star
26

go-listener

TCP listener on roids
Go
3
star
27

crosstool-ng-arm

Docker image with crosstool-ng for ARM (Raspberry Pi)
Shell
3
star
28

talkinator

a talking akinator
Python
3
star
29

pyascii85

Ascii85 encoder and decoder for python
C
3
star
30

linvpn

Secure socket layer for pppd (legacy)
C
2
star
31

b3-geoip-plugin

IP Geolocation plugin for the Big Brother Bot
Python
2
star
32

fiorix.github.com

HTML
2
star
33

pbserver

pbcopy and pbpaste over the web
Python
1
star