Go Makefile
Clone or download
Latest commit f09bb2c Jun 7, 2018
Permalink
Failed to load latest commit information.
.github contributing Nov 2, 2017
cmd using run instead of output, update man pages Jun 6, 2018
example build on .travis May 29, 2018
man using run instead of output, update man pages Jun 6, 2018
.gitignore using go dep Sep 19, 2017
.travis.yml build then test May 31, 2018
CHANGELOG.md using run instead of output, update man pages Jun 6, 2018
CONTRIBUTING.md ⭐️ Nov 23, 2017
Dockerfile using run instead of output, update man pages Jun 6, 2018
Gopkg.lock update dep and man May 23, 2018
Gopkg.toml update dep and man May 23, 2018
LICENSE Initial commit Jun 30, 2016
Makefile lint Jun 7, 2018
README.md package cloud badges Jun 6, 2018
a_test.go DurationRound Feb 15, 2017
color.go new file: color.go Feb 17, 2017
color_test.go new file: color_test.go Feb 17, 2017
config.go implementing require_cmd May 29, 2018
ctl.go PurgeServices clear when files <=2 Nov 4, 2017
ctl_test.go improve PurgeServices to avoid accidents Mar 26, 2017
daemon.go implements PR #39 Use service name derived from config when using `im… Apr 22, 2018
daemon_test.go PurgeServices clear when files <=2 Nov 4, 2017
flags.go Nodaemon flag May 14, 2018
fork.go comment in fork Nov 23, 2017
fork_test.go https://talks.golang.org/2013/bestpractices.slide#28 Aug 22, 2016
funcs.go implements PR #39 Use service name derived from config when using `im… Apr 22, 2018
funcs_test.go Test for GetUserSdir Apr 30, 2018
kqueue.go dir Fflags: syscall.NOTE_WRITE | syscall.NOTE_ATTRIB, Jul 10, 2017
kqueue_386.go modified: kqueue_386.go May 17, 2017
kqueue_arm.go modified: kqueue_386.go May 17, 2017
kqueue_test.go using one channel May 10, 2017
logger.go NewStderrLogger Sep 6, 2017
logger_test.go loggerstderr test Sep 7, 2017
openmode.go watch on start either service start or not Apr 18, 2017
openmode_darwin.go watch on start either service start or not Apr 18, 2017
parser.go Better help text May 15, 2018
parser_test.go implementing require_cmd May 29, 2018
process.go check if using interface is the way to go in Daemon.Run Jan 6, 2018
process_test.go NewStderrLogger Sep 6, 2017
scandir.go lint Jun 7, 2018
scandir_linux.go scandir_linux using normal map Nov 3, 2017
scandir_linux_test.go lock test (linux) Jul 13, 2017
scandir_test.go scandir test Nov 6, 2017
signals.go signals only sent when process is running Jan 8, 2018
signals_test.go golint Oct 30, 2017
socket.go check if using interface is the way to go in Daemon.Run Jan 6, 2018
supervise.go IMMORTAL_EXIT Jan 4, 2018
supervise_test.go removed info.go Nov 2, 2017
watchpid.go syscall.Close(kq) Apr 11, 2017
watchpid_386.go moved supervisor to daemon Oct 26, 2016
watchpid_arm.go moved supervisor to daemon Oct 26, 2016
watchpid_linux.go moved supervisor to daemon Oct 26, 2016
watchpid_test.go renamed: off/watchpid_test.go -> watchpid_test.go Nov 23, 2016

README.md

⭕ immortal

Build Status Coverage Status codecov Go Report Card

A *nix cross-platform (OS agnostic) supervisor

https://immortal.run/

GitHub release GoDoc contributions welcome

Linux precompiled binaries

deb rpm

run on behalf other system user

If services need to run on behalf other system user www, nobody, www-data, not root, immortal should be compiled from source for the desired target/architecture, otherwise, this error may be returned:

Error looking up user: "www". user: Lookup requires cgo

See more: https://golang.org/cmd/cgo/

If using FreeBSD or macOS you can install using pkg/ports or homebrew, for other platforms work is in progress, any help for making the port/package for other systems would be appreciated.

Compile from source

Setup go environment https://golang.org/doc/install

go >= 1.9 is required

For example using $HOME/go for your workspace

$ export GOPATH=$HOME/go

Create the directory:

$ mkdir -p $HOME/go/src/github.com/immortal

Clone project into that directory:

$ git clone git@github.com:immortal/immortal.git $HOME/go/src/github.com/immortal/immortal

Build by just typing make:

$ cd $HOME/go/src/github.com/immortal/immortal
$ make

To install/uninstall:

$ make install
$ make uninstall

configuration example

Content of file /usr/local/etc/immortal/www.yml:

# pkg install go-www
cmd: www
cwd: /usr/ports
log:
    file: /var/log/www.log
    age: 10  # seconds
    num: 7   # int
    size: 1  # MegaBytes
wait: 1
require:
  - foo
  - bar

If foo and bar are not running, the service www will not be started.

foo and bar are the names for the services defined on the same path www.yaml is located, foo.yml & bar.yml

Paths

When using immortaldir:

/usr/local/etc/immortal
|--foo.yml
|--bar.yml
`--www.yml

The name of the file.yml will be used to reference the service to be daemonized excluding the extension .yml.:

foo
bar
www

/var/run/immortal/

/var/run/immortal
|--foo
|  |-lock
|  `-immortal.sock
|--bar
|  |-lock
|  `-immortal.sock
`--www
   |-lock
   `-immortal.sock

immortal like non-root user

Any service launched like not using using immortaldir will follow this structure:

~/.immortal
|--(pid)
|  |--lock
|  `--immortal.sock
|--(pid)
|  |--lock
|  `--immortal.sock
`--(pid)
   |--lock
   `--immortal.sock

immortalctl

Will print current status and allow to manage the services

debug

pgrep -fl "immortal -ctl"  | awk '{print $1}' | xargs watch -n .1 pstree -p

Test status using curl & jq

status:

curl --unix-socket immortal.sock http:/status -s | jq

note the single '/' https://superuser.com/a/925610/284722

down:

curl --unix-socket immortal.sock http://im/signal/d -s | jq

up:

curl --unix-socket immortal.sock http://im/signal/u -s | jq