Skip to content
This repository has been archived by the owner. It is now read-only.
Boot once, run many times, for Ruby processes
Ruby C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
client Update printing Jan 16, 2014
example Update docs and example Dec 26, 2013
ext Add Linux support for identity Dec 31, 2013
lib Bump version Feb 4, 2014
.gitignore Add Linux support for identity Dec 31, 2013
Gemfile Initial commit Dec 25, 2013
LICENSE.txt Initial commit Dec 25, 2013
README.md Update docs and example Dec 26, 2013
Rakefile Initial commit Dec 25, 2013
poseidon.gemspec Add missing import Feb 4, 2014

README.md

Poseidon

A simple utility to allow boot-once, run as many times as you want, for Ruby applications.

Usage

require 'poseidon'
poseidon = Poseidon.new

poseidon.run do
  puts "This code is run in the context of the client"
  puts "Arguments: #{ARGV.inspect}"
end

How it works

The Poseidon server loads the code for your project and then listens on a UNIX socket for connections. The client connects and sends the following:

  • Command-line arguments
  • Standard input, standard output, standard error

The server then forks, reopens its input/output/error, and the subprocess executes. Once the subprocess exits, the master responds to the client with the exitstatus, at which point the client quits.

Prior art

Zeus is a much more featureful implementation of the same concept: https://github.com/burke/zeus.

However, Poseidon's simplicity makes it suitable for running in production. I recommend using it in environments where you need to boot many copies of a Ruby script. My main use-case is for non-interactive login shells (think git-shell).

Limitations

Poseidon does not currently change the forked process's controlling terminal, meaning you shouldn't use it for things like interactive shells.

You can’t perform that action at this time.