Skip to content
A *nix cross-platform (OS agnostic) supervisor
Go Makefile Rust Dockerfile
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci remove dep from circleci Mar 22, 2020
.github Go modules (#58) Mar 22, 2020
cmd clean up the help menu for immortalctl Mar 8, 2019
example [Issue 36] Updated readme for avoiding log rotate (#52) Oct 6, 2019
man [Issue 36] Updated readme for avoiding log rotate (#52) Oct 6, 2019
rust move Cargo & src to rust directory Mar 22, 2020
.gitignore 🦀 starting oxidation Oct 21, 2019
.travis.yml Go modules (#58) Mar 22, 2020
CHANGELOG.md
CONTRIBUTING.md Nov 23, 2017
Dockerfile using run instead of output, update man pages Jun 6, 2018
LICENSE Initial commit Jun 30, 2016
Makefile lint Jun 7, 2018
README.md require go >= 1.12 Oct 20, 2019
a_test.go fix to prevent signal: broken pipe, thanks @honteng Dec 16, 2018
color.go new file: color.go Feb 17, 2017
color_test.go new file: color_test.go Feb 17, 2017
config.go implements #54 Oct 20, 2019
ctl.go PurgeServices clear when files <=2 Nov 4, 2017
ctl_test.go improve PurgeServices to avoid accidents Mar 26, 2017
daemon.go * Implemented `retries 0` defaults to `-1` run forever, if set to 0 i… Sep 22, 2018
daemon_test.go cleaned tests Sep 23, 2018
flags.go implemented option -cc Mar 7, 2019
fork.go comment in fork Nov 23, 2017
fork_test.go https://talks.golang.org/2013/bestpractices.slide#28 Aug 22, 2016
funcs.go * Implemented `retries 0` defaults to `-1` run forever, if set to 0 i… Sep 22, 2018
funcs_test.go Test for GetUserSdir Apr 30, 2018
go.mod Go modules (#58) Mar 22, 2020
go.sum Go modules (#58) Mar 22, 2020
kqueue.go Add support for freebsd/arm64 (#55) Dec 8, 2019
kqueue_386.go modified: kqueue_386.go May 17, 2017
kqueue_arm.go modified: kqueue_386.go May 17, 2017
kqueue_test.go
logger.go Not to close pipe even when Scan() fails (#46) Dec 16, 2018
logger_test.go Cleanup test removing unnecessary breaks Dec 16, 2018
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 test for option -cc Mar 7, 2019
parser_test.go test for option -cc Mar 7, 2019
process.go check if using interface is the way to go in Daemon.Run Jan 6, 2018
process_test.go * Implemented `retries 0` defaults to `-1` run forever, if set to 0 i… Sep 22, 2018
scandir.go set defaults in yml parser + tests Sep 23, 2018
scandir_linux.go * Implemented `retries 0` defaults to `-1` run forever, if set to 0 i… Sep 22, 2018
scandir_linux_test.go lock test (linux) Jul 13, 2017
scandir_test.go scandir test Nov 6, 2017
signals.go * Implemented `retries 0` defaults to `-1` run forever, if set to 0 i… Sep 22, 2018
signals_test.go cleaned tests Sep 23, 2018
socket.go set defaults in yml parser + tests Sep 23, 2018
socket_test.go test failed socket Sep 23, 2018
supervise.go pass as string post_exit and exitcode Oct 20, 2019
supervise_test.go * Implemented `retries 0` defaults to `-1` run forever, if set to 0 i… Sep 22, 2018
watchpid.go Add support for freebsd/arm64 (#55) Dec 8, 2019
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

CircleCI 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.12 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. Skip age, num & size options to avoid log-rotation completely.

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
You can’t perform that action at this time.