https://github.com/cloud66-oss/morta
Kills Processes with Grace
https://github.com/cloud66-oss/morta
kubernetes linux shutdown signal workers
Last synced: about 2 months ago
JSON representation
Kills Processes with Grace
- Host: GitHub
- URL: https://github.com/cloud66-oss/morta
- Owner: cloud66-oss
- Created: 2020-04-03T10:59:29.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-22T11:00:46.000Z (over 1 year ago)
- Last Synced: 2025-06-08T16:02:47.761Z (12 months ago)
- Topics: kubernetes, linux, shutdown, signal, workers
- Language: Go
- Homepage: https://www.cloud66.com
- Size: 3.04 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# morta
Given a process PID and a sequence of alternating signals and sleep durations, morta will perform the sequence against the PID until either the process is dead, or the sequence has completed.
# Installation
Head to the morta [releases](https://github.com/cloud66-oss/morta/releases/latest) and download the latest version for your platform.
You can then copy the file to /usr/local/bin and make sure it is renamed to morta, and that it is executable via `chmod +x /usr/local/bin/morta`. From this point on, you can run `morta update` to update it automatically.
# Usage
Let's use [unicorn](https://github.com/defunkt/unicorn) as an example, which is an HTTP server for Rack applications. Looking at its [help page for signals](https://github.com/defunkt/unicorn/blob/master/SIGNALS), we can see the following signals defined for the master process:
Signal | Result
--- | ---
QUIT | graceful shutdown, waits for workers to finish their current request before finishing
INT/TERM | quick shutdown, kills all workers immediately
KILL | terminate process immediately, uncatchable
From this, a reasonable sequence of signals might be the following:
- send SIGQUIT to the master process if it exists
- wait 30 seconds or until master is dead, whichever comes first
- send SIGTERM to the master process if it exists
- wait 10 seconds or until master is dead, whichever comes first
- send SIGKILL to the master process if it exists
Assuming that the master unicorn process has a PID of 1234, you can then run the following to perform the above sequence:
```
$ morta -p 1234 -s "quit:30:term:10:kill"
```
You can then use this in your process manager to terminate the process as cleanly as possible. For example, if you're using [systemd](https://www.freedesktop.org/wiki/Software/systemd/), you can add the following to your service definition:
```
ExecStop=-/usr/local/bin/morta -p $MAINPID -s "quit:30:term:10:kill"
```
## Update
Manually checks for updates. It can also switch the current release channel.
```
$ morta update [--channel name]
```
## Version
Shows the channel and the version
```
$ morta version
```