• Stars
    star
    642
  • Rank 70,096 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Zero downtime restarts for your apps

socketmaster(1) -- Zero downtime restart for your apps

SYNOPSIS

socketmaster [-listen=URI] [-command=PATH] [-start=MILLIS] [-syslog]

DESCRIPTION

socketmaster is a generic solution to the restart problem: you want to restart your app but neither lose any active connection nor refuse new connections.

socketmaster opens the socket you want to listen on and passes it onto your program. Because socketmaster is simple enough it doesn't need to be restarted and can keep your file-descriptor indefinitely open.

  • -command=PATH: Defines the location of the program to execute and pass the file-descriptor onto. If you need to add arguments to the program, use -- before the command specific arguments or use a wrapper script.

    e.g. socketmaster -command -- -arg1 -arg2

  • -listen=URI: One of the following schemes are accepted: tcp, tcp4, tcp6 and unix. Example: tcp4://localhost:8945 or unix:///tmp/myapp.sock

  • -start=MILLIS: Determines how long socketmaster waits before signaling the old process. If MILLIS is set to zero that feature is disabled.

  • -syslog: Tells socketmaster to log to syslog.

  • -user=LOGIN: Sets the child process's uid/gid to the given user (looked up in /etc/passwd). This command only works when socketmaster is run as root.

HOW IT WORKS

On start:

  • socketmaster open the -listen port
  • socketmaster starts the -command with the socket on fd 3 and EINHORN_FDS=3
  • as soon as all child processes are gone, socketmaster stops as well

On SIGUSR1:

  • socketmaster restarts itself with the same command line options
    • without dropping or refusing any connections

On SIGHUP:

  • socketmaster starts a new -command
  • waits for -start milliseconds
  • sends a SIGTERM to the other child processes

Your server is responsible for:

  • opening the socket passed on fd 3
  • not crashing
  • gracefully shutdown on SIGTERM (close the listener, wait for the child connections to close)

ENVIRONMENT

  • EINHORN_FDS: This variable is set by socketmaster and passed onto the children. Its value is always 3 and meant for einhorn compatibility.

SIGNALS

On SIGHUP, socketmaster starts a new child process, waits for -start and sends a HUP to the old process.

SIGINT, SIGTERM and SIGQUIT are forwarded to the child processes.

RELATED PROJECTS

BUGS & CODE

Bug reports and other contributions are welcome! The project's source and issue tracker is located at https://github.com/zimbatm/socketmaster/

COPYRIGHT

socketmaster is Copyright (C) 2012 PandaStream http://pandastream.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the โ€œSoftwareโ€), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED โ€œAS ISโ€, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

ffmpeg-static

Scripts to build ffmpeg with all the deps statically (webm + h264 included)
Shell
507
star
2

mdsh

`$ mdsh` # a markdown shell pre-processor
Rust
105
star
3

hostnames-and-usernames-to-reserve

Blacklist of hostnames and users all PaaS should use
HTML
62
star
4

shab

the bash templating language
Nix
52
star
5

h

faster shell navigation of projects
Ruby
32
star
6

wiki

This content has moved to Notion
HTML
31
star
7

nodejs-http-websocket

[OUTDATED] node.js WebSocket implementation on top of the stdlib HTTP server
JavaScript
20
star
8

home

@zimbatm's home
Nix
18
star
9

lines

structured logs for humans
14
star
10

lines-ruby

Lines - structured logs for humans - ruby edition
Ruby
13
star
11

vscode-devcontainer-nix

WIP: VSCode remote container for Nix-based environments
Dockerfile
12
star
12

nix-experiments

Nix
12
star
13

project-zomboid-demo

Mac and Linux adaptation of the demo runner. Buy their game !
Shell
11
star
14

publicsuffix.js

JavaScript version of the Public Suffix List
JavaScript
8
star
15

httputil2

What should really be in golang's net/http/httputil package.
Go
7
star
16

nixos-wiki-test

JavaScript
7
star
17

http-caching-proxy

HTTP to S3 cache hostable on Heroku
Go
7
star
18

HowDareYouApp

Angry french man
JavaScript
6
star
19

project-zomboid-launcher

Project Zomboid - Launcher for Linux and OSX
Ruby
5
star
20

namespace.rb

Experiment: Bringing namespaces to Ruby
Ruby
5
star
21

facts

Exploration of stack-based languages
Ruby
4
star
22

learn-to-walk-with-chef

Ruby
4
star
23

elm-gamepad

Elm wrapper around the W3C Gamepad API
JavaScript
4
star
24

logmail

Send your mails to syslog
Shell
4
star
25

project-euler-solutions

Some of my solutions to Project Euler
Haskell
4
star
26

nix-cpp-demo

Nix
4
star
27

putio-sync

A simple put.io fetcher script. Keep local copies of the files.
Ruby
4
star
28

nix-path

WIP: per project NIX_PATH
Nix
4
star
29

heretic-nix

Using __noChroot for good
Nix
4
star
30

mediasniff

Media capturing tool - Probably needs some work since node moves so fast
JavaScript
3
star
31

haproxy.vim

Vim Script
3
star
32

freepass

Per domain password generation tool [Unmaintained]
JavaScript
3
star
33

aerofs-docker

Docker container for the AeroFS Team Server
Shell
3
star
34

rake-plus

Delicious rake extensions
Ruby
3
star
35

camlistore-docker

Docker container for Camlistore
Shell
3
star
36

relative-require.rb

Relative require to the file loading in ruby
Ruby
2
star
37

mc.0x2a.im

Minecraft server configuration
Shell
2
star
38

go-secretvalue

Go
2
star
39

jsonpp

Command-line JSON pretty-printer
Ruby
2
star
40

docker-redis-server

Minimal docker redis-server image
Shell
2
star
41

browser-error-reporter

Be notified of all those nasty client errors
JavaScript
2
star
42

rb-pkg

Ruby packaging technology
Ruby
2
star
43

Allow-app

unlock your quarantined files
2
star
44

experiment-nix-build-diff

Nix
2
star
45

nixos-org

Prototype for a declarative NixOS organization
Nix
2
star
46

nix-snowflake-sticker

Sticker produced for NixCon 2022
2
star
47

miniby

Experiment: Markaby meets HTML5
Ruby
1
star
48

deb-beanstalkd

Lucid package of beanstald 1.4.6
Shell
1
star
49

methodchain

Replace methods in an existing class but keep super
Ruby
1
star
50

neuron

Testing neuron
Markdown
1
star
51

u-web

[HACK] micro MVC framework in a single ruby file
Ruby
1
star
52

flake-static

Nix
1
star
53

nix-benchmark

Trying to better understand where Nix spends its time
1
star
54

deb-redis

Updated lucid package of redis
C
1
star
55

deb-rubygems

Ubuntu package of 1.8.6 (using git-buildpackage)
Ruby
1
star
56

terraform-nixos-demo

Nix Friday episode: https://www.youtube.com/watch?v=LJ-blO8FLAY
HCL
1
star
57

u-log

U::Log - a different take on logging
Ruby
1
star
58

code-learn

Best way to learn is to code. Big pile of hacky code used to check-out some properties of languages
Ruby
1
star
59

monkeypatch

Safe(er) monkey patching in Ruby
Ruby
1
star
60

direnv-and-nix-talk

HTML
1
star
61

deb-mongodb

Lucid build of mongodb 1.6.5
C++
1
star