-
Notifications
You must be signed in to change notification settings - Fork 217
Server
Eduardo Sebastian edited this page Jan 14, 2014
·
7 revisions
Goliath uses its own event based server built on top of EventMachine. As shown in the example above, to start the server, you just need to have Ruby to execute your Goliath API file. The server accepts some optional parameters described below:
Server options:
-e, --environment NAME Set the execution environment (prod, dev or test) (default: development)
-a, --address HOST Bind to HOST address (default: 0.0.0.0)
-p, --port PORT Use PORT (default: 9000)
-S, --socket FILE Bind to unix domain socket
Daemon options:
-u, --user USER Run as specified user
-c, --config FILE Config file (default: ./config/<server>.rb)
-d, --daemonize Run daemonized in the background (default: false)
-l, --log FILE Log to file (default: off)
-s, --stdout Log to stdout (default: false)
-P, --pid FILE Pid file (default: off)
SSL options:
--ssl Enables SSL (default: off)
--ssl-key FILE Path to private key
--ssl-cert FILE Path to certificate
--ssl-verify Enables SSL certificate verification
Common options:
-C, --console Start a console
-v, --verbose Enable verbose logging (default: false)
-h, --help Display help message
Note that the default environment could be set in your code using the Goliath.env=
method call.
Here is an example of how to start a production Goliath API daemonized and on port 92010. If not set, the default goliath pid and log files will be used.
$ ruby awesome_api.rb -e prod -p 92010 -d
The server will automatically load the API matching the file name. If your api file is named awesome_api.rb, the server will expect that you have an AwesomeApi
class inheriting from Goliath::API
.