123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- .\" generated with Ronn/v0.7.3
- .\" http://github.com/rtomayko/ronn/tree/0.7.3
- .
- .TH "SHOTGUN" "1" "February 2011" "Shotgun 0.9" ""
- .
- .SH "NAME"
- \fBshotgun\fR \- reloading rack development server
- .
- .SH "SYNOPSIS"
- \fBshotgun\fR [\fIoptions\fR] [\fIrackup\-file\fR]
- .
- .SH "DESCRIPTION"
- \fBShotgun\fR is a simple process\-per\-request Rack \fIhttp://rack\.rubyforge\.org/doc/README\.html\fR server designed for use in development environments\. Each time a request is received, \fBshotgun\fR forks, loads the \fIrackup\-file\fR, processes a single request and exits\. The result is application\-wide reloading of all configuration, source files, and templates without the need for complex application\-level reloading logic\.
- .
- .P
- When no \fIrackup\-file\fR is given, \fBshotgun\fR uses the \fBconfig\.ru\fR file in the current working directory\.
- .
- .SH "OPTIONS"
- Shotgun runs at \fBhttp://127\.0\.0\.1:9393\fR by default\. The following options control server behavior:
- .
- .TP
- \fB\-E\fR, \fB\-\-env\fR=\fIenvironment\fR
- Sets the \fBRACK_ENV\fR environment variable to \fIenvironment\fR and selects the default set of utility middleware\. When \fIenvironment\fR is \'development\', shotgun inserts the \fBRack::Lint\fR and \fBRack::CommonLogger\fR middleware components; when \fIenvironment\fR is \'production\' or \'deployed\', \fBRack::CommonLogger\fR is inserted; otherwise, no utility middleware are inserted\.
- .
- .TP
- \fB\-P\fR, \fB\-\-public\fR=\fIpath\fR
- Serve requests for static files that exist under \fIpath\fR from the shotgun master process without forking a worker process\. This option is automatically enabled when a \fB\./public\fR directory is detected, but can be configured explicitly for non\-conventional static file directory locations\.
- .
- .IP
- Setting this option appropriately can severely improve overall page load times for applications with many static assets\.
- .
- .TP
- \fB\-s\fR, \fB\-\-server\fR=\fImongrel\fR|\fIwebrick\fR|\fIthin\fR|\fIother\fR
- The Rack server handler implementation used to serve requests\. Supported values include: \fBmongrel\fR, \fBwebrick\fR, and \fBthin\fR\. By default, shotgun first tries to use \fBmongrel\fR and falls back to \fBwebrick\fR if mongrel is not available\.
- .
- .TP
- \fB\-o\fR, \fB\-\-host\fR=\fIaddr\fR
- The hostname or address of the interface the HTTP server should bind to\. Default: \fB127\.0\.0\.1\fR\.
- .
- .TP
- \fB\-p\fR, \fB\-\-port\fR=\fIport\fR
- The port the HTTP server should bind to\. Default: \fB9393\fR\.
- .
- .TP
- \fB\-O\fR, \fB\-\-browse\fR
- Open browser at http://\fIhost\fR:\fIport\fR/ immediately after the server is started\.
- .
- .P
- Ruby environment related options:
- .
- .TP
- \fB\-r\fR, \fB\-\-require\fR \fIlibrary\fR
- Require \fIlibrary\fR before loading the application and starting the server\. This can be used to load a portion of the application code in the master process so it doesn\'t need to be loaded in the child\. See \fIPRELOADING\fR][] for more information on this approach\.
- .
- .TP
- \fB\-e\fR, \fB\-\-eval\fR \fIcommand\fR
- Evaluate arbitrary \fIcommand\fR within the shotgun master Ruby interpreter\. \fIcommand\fR is evaluated as program arguments are parsed\. Multiple \fB\-e\fR arguments are allowed\.
- .
- .TP
- \fB\-d\fR, \fB\-\-debug\fR
- Turns on debug mode\. \fB$DEBUG\fR will be set \fBtrue\fR\.
- .
- .TP
- \fB\-w\fR, \fB\-\-warn\fR
- Enable verbose mode without printing version message at the beginning\. It sets the \fB$VERBOSE\fR variable to true\.
- .
- .TP
- \fB\-I\fR, \fB\-\-include\fR \fIpath\fR
- Add \fIpath\fR to the Ruby load path (\fB$LOAD_PATH\fR)\. May be used more than once\.
- .
- .P
- Miscellaneous:
- .
- .TP
- \fB\-h\fR, \fB\-\-help\fR
- Show usage message and exit\.
- .
- .TP
- \fB\-\-version\fR
- Show the Rack version and exit\.
- .
- .SH "PRELOADING"
- It\'s possible to load support libraries and portions of the application in the shotgun master process to reduce the amount of work that needs to be done for each request in worker processes\. There\'s two ways of accomplishing this: either by specifying one or more \fB\-\-require\fR (\fB\-r\fR) arguments or through the use of a \fBshotgun\.rb\fR file\.
- .
- .P
- During start up, shotgun looks for a \fBshotgun\.rb\fR or \fBconfig/shotgun\.rb\fR file\. If either file is found, it\'s loaded into the shotgun master process\. Code at the top\-level of the \fBshotgun\.rb\fR is run once on startup, so just require whatever you want to preload\. It\'s also possible to register callbacks to run before each request in either the master or child worker process:
- .
- .TP
- \fBafter_fork {\fR \fIstuff\fR \fB}\fR
- Run \fIstuff\fR in the shotgun child worker process immediately after forking\. Any files or socket connections opened in the master process should be closed / re\-established by an \fBafter_fork\fR block\.
- .
- .TP
- \fBbefore_fork {\fR \fIstuff\fR \fB}\fR
- Run \fIstuff\fR in the shotgun master process on each request before forking the child worker process\. This is typically less useful than \fBafter_fork\fR, but provided for completeness\.
- .
- .P
- Example \fBconfig/shotgun\.rb\fR file from the main github\.com rails project:
- .
- .IP "" 4
- .
- .nf
- # make sure the load path includes RAILS_ROOT
- ENV[\'RAILS_ROOT\'] ||= File\.expand_path(\'\.\./\.\.\', __FILE__)
- $:\.unshift ENV[\'RAILS_ROOT\']
- # bring in the base rails environment and some libraries
- require \'config/environment\'
- require \'google\-charts\'
- require \'aws\-s3\'
- # disable Rails\'s built in class reloading
- Rails\.configuration\.cache_classes = true
- # reset database and redis connections in workers
- after_fork do
- ActiveRecord::Base\.establish_connection
- CHIMNEY\.client = $redis
- end
- .
- .fi
- .
- .IP "" 0
- .
- .SH "INSTALLING"
- Shotgun is distributed as a gem package at rubygems\.org:
- .
- .P
- \fIhttp://rubygems\.org/gems/shotgun\fR
- .
- .br
- \fBgem install shotgun\fR
- .
- .P
- The \fBrack\fR package is required\. The \fBmongrel\fR package is recommended\.
- .
- .SH "CONTRIBUTING"
- Fork and report issues at github\.com:
- .
- .P
- \fIhttp://github\.com/rtomayko/shotgun/\fR
- .
- .br
- \fBgit clone git://github\.com/rtomayko/shotgun\.git\fR
- .
- .SH "VERSION HISTORY"
- .
- .SS "Version 0\.9 (2011 February 24)"
- .
- .IP "\(bu" 4
- \fIhttp://github\.com/rtomayko/shotgun/compare/0\.8\.\.\.0\.9\fR
- .
- .IP "\(bu" 4
- Various Ruby 1\.9\.2 fixes\.
- .
- .IP "\(bu" 4
- Handle application class names consisting of multiple words\.
- .
- .IP "" 0
- .
- .SS "Version 0\.8 (2010 June 24)"
- .
- .IP "\(bu" 4
- \fIhttp://github\.com/rtomayko/shotgun/compare/0\.7\.\.\.0\.8\fR
- .
- .IP "\(bu" 4
- Preloading support\. The \fBshotgun\.rb\fR or \fBconfig/shotgun\.rb\fR file is loaded at startup and may require libraries and register callbacks for fork events\. See the section on \fIPRELOADING\fR\.
- .
- .IP "\(bu" 4
- Fix starting with the Thin handler (\fBshotgun \-s thin\fR)
- .
- .IP "\(bu" 4
- Actually include the shotgun(1) roff manual\.
- .
- .IP "" 0
- .
- .SS "Version 0\.7 (2010 June 22)"
- .
- .IP "\(bu" 4
- \fIhttp://github\.com/rtomayko/shotgun/compare/0\.6\.\.\.0\.7\fR
- .
- .IP "\(bu" 4
- Static files now served from the shotgun master process, making shotgun tolerable for apps with many/unbundled static assets\.
- .
- .IP "\(bu" 4
- Added \fB\-\-public\fR (\fB\-P\fR) for specifying a non\-standard root / public directory\.
- .
- .IP "\(bu" 4
- Response bodies are now streamed over the master < worker pipe instead of being marshalled\. Improves performance with large response bodies, and reduces shotgun master process RES usage\.
- .
- .IP "\(bu" 4
- GET /favicon\.ico requests are served an empty response by the shotgun master process\. Prevents the need to fork a worker process\.
- .
- .IP "\(bu" 4
- \fBINT\fR, \fBTERM\fR, \fBQUIT\fR now properly trigger server shutdown\. The second \fBINT\fR, \fBTERM\fR, \fBQUIT\fR causes the master process to exit hard\.
- .
- .IP "\(bu" 4
- Non \fB\.ru\fR config files (e\.g\., sinatra app files) may now define command line options in the same way as \fB\.ru\fR files: by including a \fB#\e \-p 5555 \.\.\.\fR line\.
- .
- .IP "" 0
- .
- .SS "Versions < 0\.7 (2009\-2010)"
- .
- .IP "\(bu" 4
- \fIhttp://github\.com/rtomayko/shotgun/commits/0\.6\fR
- .
- .IP "" 0
- .
- .SH "SEE ALSO"
- ruby(1)
|