Skip to content
BJ Neilsen edited this page Sep 13, 2013 · 2 revisions

Services need to be hooked up to a socket to be called by clients. Use the provided program rpc_server:

$ rpc_server -o myserver.com -p 9399 -l ./log/protobuf.log ./config/environment.rb

The previous call will start a Socket server running on the given host and port which will load your application into memory. You certainly don't have to run rails or any other framework, just make sure you have some kind of file that will load your services all into memory. The server doesn't know where you put your code, so tell it.

Protobuf messages are non-self-describing, that is, they don't know their own type when serialized to bytes. All requests come across serialized in a known wrapper type so that we can deserialize. The wrapper type contains a string that denotes the service class to invoke, and will simply constantize the string. Hence, your service implementations and compiled definitions must be loaded before any requests can be handled. It's necessary to store all your definitions and their generated classes in a shared repository (like a gem) so that both client and server have access to the ruby classes in their respective load paths.

Once the server starts, you should see it as a running process with ps. Sending a KILL, QUIT, or TERM signal to the pid will result in shutting the server down gracefully.

$ ps aux | grep rpc_server
1234 ... rpc_server myserver.com:9399

$ kill -QUIT 1234
rpc_server shutdown
Clone this wiki locally