GithubHelp home page GithubHelp logo

go-daemon's Introduction

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.

go-daemon's People

Contributors

fiorix avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.