Project

machinegun

0.0
No commit activity in last 3 years
No release in over 3 years
An automatic reloading Rack development web server for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.4
>= 0
>= 0
~> 3.3.0
~> 1.2.0
>= 0

Runtime

~> 0.5.2
>= 1.6.4, ~> 1.6
 Project Readme

machinegun

Gem Version Coverage Status API Documentation MIT License

An automatic reloading Rack development web server for Ruby.

This gem was inspired by shotgun, which reloads the application on every request to ensure that the latest code is running. However, reloading on request can cause performance problems for applications that consume a lot of memory and/or generate a lot of requests. machinegun solves this problem by reloading the application when there are changes to the filesystem, instead of reloading on each request. This allows for the best of both worlds: A web server that reloads when changes to the code are made, and also performs quickly when serving requests.

End Of Life Notice

This library is no longer being maintained. The original goal was to replace shotgun with a web server that reloads on file system changes for better performance. When developing web applications, it has become best practice to run the application in a virtual machine or Docker container during development. This can impede the file system inotify events emitted by the guest from propagating to the host, thereby defeating the file watching mechanism (it falls back to polling, which is resource intensive). A better alternative is to run a web server like unicorn or puma inside the container, with a file watcher running on the host. The file watcher can then notify the containerized webserver to restart by sending it the appropriate system signal (typically SIGUSR1). This solution has much higher throughput than a webrick-based solution like shotgun or machinegun, and is great for single-page applications or other apps that make many HTTP requests per page load.

Installation

$ gem install machinegun

Use

The machinegun command replaces rackup. rackup's command line options should be compatible with the machinegun executable. Since machinegun is a wrapper around Rack, your project also needs a Rack configuration file, typically config.ru.

For example, the following command will launch the web server on port 9393 and bind it to all network adapters:

$ machinegun -p 9393 -o 0.0.0.0

Development

To skip the integration tests during development, run the test suite with:

$ SKIP_INTEGRATION_TESTS=true bundle exec rake