bobthecow / genghis

The single-file MongoDB admin app
http://genghisapp.com
MIT License
1.45k stars 166 forks source link

Using gem with nginx and unix socket #134

Closed maxvipon closed 11 years ago

maxvipon commented 11 years ago

Is there a way to somehow configure gem and use It with unix socket instead 0.0.0.0:5678 and nginx as proxy?

bobthecow commented 11 years ago

Yes. Not just one, but many ways :)

One example, using Thin:

Add this Gemfile to a project folder:

source 'https://rubygems.org'
gem 'genghisapp'
gem 'thin'

And this config.ru:

require 'genghis'
run Genghis::Server

Run bundle install to install all dependencies.

You'll start Genghis like this:

bundle exec thin start -R config.ru --socket /tmp/genghis.sock

How exactly you start and keep Genghis running depends very much on your system, but you might use monit or god or some init.d script or something.

Now point Nginx to /tmp/genghis.sock and you're set!