Installing Scribe on OSX with Thrift 0.5.0
Update (2011-02-24)
This also works on Ubuntu, with two little tweaks.
First, no need to install libevent from source, just do an apt-get install libevent-dev.
Second, after you install Scribe, you need to add Thrift to the shared library path so it will load.
Just add a new file called /etc/ld.so.conf.d/scribe.conf with this content:
/opt/thrift/lib
/opt/scribe/lib
/opt/fb303/lib
Then run ldconfig and you should be good to go.I looked for a way to install Facebook's Scribe on OS X to test out some code I'm writing at work, but I could not find a process that worked for me.
The best I got was by @kpumuk called Installing and Using Scribe with Ruby on Mac OS.
It got me close, but what I outline below got me the rest of the way. Hopefully it will help you (until it breaks too)
Install libevent (2.0.10)
You'll need the development files for libevent, which you probably don't have. Grab the latest stable package at http://monkey.org/~provos/libevent/. I used 2.0.10.
This one is easy, just configure and make install.
$ sudo ./configure
$ sudo make install
You might consider using --prefix=/opt/libevent on the configure to keep this libevent separate from any others that might get installed (via brew or ports). If so, be sure to change --with-libevent when compiling Thrift.
Install Thrift (0.5.0)
Now let's install Thrift. 0.5.0 is the latest stable, and what I used. http://incubator.apache.org/thrift/.
Again, not a tough build, but you need to be sure that you set --with-libevent on configure, otherwise thriftnb won't be built and you'll have to do this compile again later when you get stuck in the Scribe build.
$ sudo ./configure --prefix=/opt/thrift --with-libevent=/usr/local/lib
$ sudo make install
Install FB303 (In Thrift source)
You also need FaceBook Baseline (FB303) which is included in the Thrift source code. From your Thrift source directory, do the following:
$ cd contrib/fb303
$ sudo ./bootstrap.sh
$ sudo ./configure --prefix=/opt/fb303 --with-thriftpath=/opt/thrift
$ sudo make install
Install Scribe (> 2ee14d3)
There is a bug fix in Scribe at version 2ee14d3, which fixes a build problem created by Thrift 0.5.0.
So, as of right now you need to get your source for Scribe from github, and after that commit.
Once you have it:
$ sudo ./bootstrap.sh
$ sudo ./configure --prefix=/opt/scribe --with-thriftpath=/opt/thrift --with-fb303path=/opt/fb303
$ sudo make install
Build Ruby Thrift structures
Okay, everything is installed now! Well, almost. You still need to generate the Thrift bindings if you are going to be using Ruby.
From the scribe source directory:
$ /opt/thrift/bin/thrift -o . -I /opt/fb303/share/ --gen rb if/scribe.thrift
$ /opt/thrift/bin/thrift -o . -I /opt/fb303/share/ --gen rb /opt/fb303/share/fb303/if/fb303.thrift
$ sudo mkdir /opt/scribe/ruby
$ sudo mv gen-rb/ /opt/scribe/ruby/scribe
Copy a config from Scribe
You'll also need a config file for Scribe, which you can get from the examples directory in the Scribe source.
Again, from the Scribe source root:
$ sudo mkdir /opt/scribe/conf/
$ sudo cp examples/example1.conf /opt/scribe/conf/test.conf
Start Scribe!
You are now ready to run scribe, so fire it up!
$ sudo /opt/scribe/bin/scribed -c /opt/scribe/conf/test.conf
Test it from Ruby
Now open up an editor and drop this into a Ruby script.
$LOAD_PATH.unshift('/opt/scribe/ruby/scribe')
require 'scribe'
begin
socket = Thrift::Socket.new('localhost', 1463)
transport = Thrift::FramedTransport.new(socket)
protocol = Thrift::BinaryProtocol.new(transport, false)
client = Scribe::Client.new(protocol)
transport.open()
log_entry = LogEntry.new(
:category => 'test',
:message => 'This is a test message'
)
client.Log([log_entry])
transport.close()
rescue Thrift::Exception => tx
print 'Thrift::Exception: ', tx.message, "\n"
end
When you run it, you should get a new directory and file in /tmp/scribetest containing your message.
Enjoy!