Coder Social home page Coder Social logo

prax's Introduction

Prax

A pure ruby alternative to Pow!!

Aka a Rack application spawner and proxy for simpler local development. Calling myapp.dev and subdomain.myapp.dev with no configuration is simpler than editing your hosts file, starting your applications manually on port 3000, etc.

Why a pure-ruby alternative?

My GNU/Linux fork of [Pow](pow.cx/) just broke on me badly, and I couldn’t read, less write the coffeescript it’s written in. I thus decided to try writing an alternative in Ruby. Good for me, because I now have a viable alternative, and learned a lot about TCP and UNIX sockets, the HTTP protocol, Rack and Ruby Threads.

Also, Prax only requires Ruby and the Rack gem, both you should have already installed if you are a Ruby Web developer.

Rubies

Prax has been developed with MRI Ruby 1.9.3, but should be compatible with most ruby engines. It has been tested on:

- Ruby 1.8.7
- Ruby 1.9.3
- Rubinius 2.0.0 (HEAD)
- JRuby 1.7.0 (1.9 mode)

Please note that Ruby 1.8.7 and Rubinius in 1.8 mode also require the ‘sfl` (spawn for legacy) gem, because Ruby 1.8 doesn’t support ‘Process.spawn` which was introduced in Ruby 1.9.

Jruby in 1.8 mode isn’t supported, because ‘sfl` requires `fork` which isn’t available on all platforms (not even GNU/Linux). Also, Jruby 1.6.8 just doesn’t work with Prax, neither in 1.8 nor 1.9 modes.

Installing on GNU/Linux

First clone the repository, install the port forwarding script and NSSwitch extension.

$ git clone git://github.com/ysbaddaden/prax.git

$ cd prax/
$ ./bin/prax install

And you’re done! You only need to link your apps using:

$ ./bin/prax link ~/Work/myapp

Or install manually:

$ sudo cp install/initd /etc/init.d/prax
$ sudo chmod +x /etc/init.d/prax
$ sudo update-rc.d prax defaults
$ sudo /etc/init.d/prax start

$ cd prax/ext/
$ make
$ sudo make install

Edit /etc/nsswitch.conf and add prax to the hosts line, then restart your browser, otherwise it won’t use the newly configured prax resolver.

Create the ~/.prax directory and link your apps to it. You may link the same folder multiple times as different names to serve it from different domains.

$ mkdir ~/.prax
$ ln -sf ~/Work/myapp ~/.prax/

Eventually start bin/prax to run Prax, point your browser to http://myapp.dev/ and wait for your Rack app to spawn.

Slowness

If you experience some regular slowness, where Prax seems to hang for periods of 5 seconds, this is because of the DNS resolution: NSSwitch tries a real DNS resolution before checking the prax extension. This usually creates an overhead of less than half a second, but sometimes takes 5 seconds on my Ubuntu 12.04.

You may try to move the ‘prax` NSSwitch extension before the `dns` one, so it looks like this:

hosts: files mdns4_minimal [NOTFOUND=return] prax dns mdns4

This will dramatically speed up the DNS resolution of *.dev domains, and it should never hang anymore. BUT please be aware that it may cause problems in regular DNS resolutions!

Mac OS X

Mac OS X isn’t supported yet. Feel free to contribute!

Features

This is a work in progress, and Prax is missing some features to be on par with Pow. Mostly on the configuration side of your development machine. Yet it’s already capable to start the HTTP server, spawn your apps, proxy requests, and more.

  • HTTP Server

  • HTTP Proxy

  • Rack Handler (Racker)

  • Rack Application spawn / restart / always restart

  • SSL support (if certs and keys are generated)

  • xip.io support

  • GNU/Linux:

    • NSSwitch DNS resolver (resolves *.dev domains to 127.0.0.1)

    • firewall rule (redirects root ports 80/443 to user ports 20559/20558)

    • install script

TODO

  • commands for the prax script:

    • prax always_restart

  • Mac OS X:

    • firewall rule

    • DNS resolver

    • install script

Credits

  • Julien Portalier <[email protected]>

  • Sam Stephenson, Nick Quaranto, 37signals for the sub comamnd

  • pyromaniac for the initial NSSwitch extension

prax's People

Contributors

ysbaddaden avatar dyson avatar jneen avatar neersighted avatar fbernier avatar ku1ik avatar rlisowski avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.