README.md in einhorn-0.3.2 vs README.md in einhorn-0.4.0
- old
+ new
@@ -66,31 +66,41 @@
...
### Server sockets
If your process is a server and listens on one or more sockets,
-Einhorn can open these sockets and pass them to the workers. Program
-arguments of the form
+Einhorn can open these sockets and pass them to the workers. You can
+specify the addresses to bind by passing one or more `-b ADDR`
+arguments:
- srv:(IP:PORT)[<,OPT>...]
- --MY-OPT=srv:(IP:PORT)[<,OPT>...]
+ einhorn -b 127.0.0.1:1234 my-command
+ einhorn -b 127.0.0.1:1234,r -b 127.0.0.1:1235 my-command
-Will be interpreted as a request to open a server socket bound to
-IP:PORT. The argument will be replaced with `FD` and `---MY-OPT=FD`,
-respectively, where `FD` is the file descriptor number of the socket.
+Each address is specified as an ip/port pair, possibly accompanied by options:
+
+ ADDR := (IP:PORT)[<,OPT>...]
+
+In the worker process, the opened file descriptors will be represented
+as a space-separated list of file descriptor numbers in the
+EINHORN_FDS environment variable (respecting the order that the `-b`
+options were provided in):
+
+ EINHORN_FDS="6" # 127.0.0.1:1234
+ EINHORN_FDS="6 7" # 127.0.0.1:1234,r 127.0.0.1:1235
+
Valid opts are:
r, so_reuseaddr: set SO_REUSEADDR on the server socket
n, o_nonblock: set O_NONBLOCK on the server socket
You can for example run:
- $ einhorn -m manual -n 4 example/time_server srv:127.0.0.1:2345,r
+ $ einhorn -b 127.0.0.1:2345,r -m manual -n 4 -- example/time_server
Which will run 4 copies of
- example/time_server 6
+ EINHORN_FDS=6 example/time_server
Where file descriptor 6 is a server socket bound to `127.0.0.1:2345`
and with `SO_REUSEADDR` set. It is then your application's job to
figure out how to `accept()` on this file descriptor.
@@ -100,10 +110,14 @@
`help` in `einhornsh` to see what admin commands you can
run). Einhorn relies on file permissions to ensure that no malicious
users can gain access. Run with a `-d DIRECTORY` to change the
directory where the socket will live.
+Note that the command socket uses a line-oriented YAML protocol, and
+you should ensure you trust clients to send arbitrary YAML messages
+into your process.
+
### Seamless upgrades
You can cause your code to be seamlessly reloaded by upgrading the
worker code on disk and running
@@ -138,13 +152,13 @@
{"command":"worker:ack", "pid":PID}
to the UNIX socket pointed to by the environment variable
`EINHORN_SOCK_PATH`. (Be sure to include a trailing newline.)
-To make things even easier, you can pass a `-b` to Einhorn, in which
+To make things even easier, you can pass a `-g` to Einhorn, in which
case you just need to `write()` the above message to the open file
-descriptor pointed to by `EINHORN_FD`.
+descriptor pointed to by `EINHORN_SOCK_FD`.
(See `lib/einhorn/worker.rb` for details of these and other socket
discovery mechanisms.)
#### Timer ACK [default]
@@ -165,24 +179,25 @@
To use preloading, just give Einhorn a `-p PATH_TO_CODE`, and make
sure you've defined an `einhorn_main` method.
In order to maximize compatibility, we've worked to minimize Einhorn's
-dependencies. At the moment Einhorn imports 'rubygems' and 'json'. (If
-these turn out to be issues, we could probably find a workaround.)
+dependencies. It has no dependencies outside of the Ruby standard
+library.
### Command name
You can set the name that Einhorn and your workers show in PS. Just
pass `-c <name>`.
### Options
- -b, --command-socket-as-fd Leave the command socket open as a file descriptor, passed in the EINHORN_FD environment variable. This allows your worker processes to ACK without needing to know where on the filesystem the command socket lives.
+ -b, --bind ADDR Bind an address and add the corresponding FD to EINHORN_FDS
-c, --command-name CMD_NAME Set the command name in ps to this value
-d, --socket-path PATH Where to open the Einhorn command socket
-e, --pidfile PIDFILE Where to write out the Einhorn pidfile
-f, --lockfile LOCKFILE Where to store the Einhorn lockfile
+ -g, --command-socket-as-fd Leave the command socket open as a file descriptor, passed in the EINHORN_SOCK_FD environment variable. This allows your worker processes to ACK without needing to know where on the filesystem the command socket lives.
-h, --help Display this message
-k, --kill-children-on-exit If Einhorn exits unexpectedly, gracefully kill all its children
-l, --backlog N Connection backlog (assuming this is a server)
-m, --ack-mode MODE What kinds of ACK to expect from workers. Choices: FLOAT (number of seconds until assumed alive), manual (process will speak to command socket when ready). Default is MODE=1.
-n, --number N Number of copies to spin up