UPDATE (Jan 9, 2015): I have not updated this project in year. While it may work, I doubt it. If you would like to take over the project, leave me a comment and we’ll get in touch.
I was reading Jason Seifer’s: Offline Gem Server Rdocs, which is an apache/passenger served Sinatra app that allows you to view the Rdocs of installed gems without using gem server. Nice. So I installed it on our sandbox server for all to enjoy.
But it got me thinking, there is another think I like to keep an eye on on our servers… log files. Oh, and I was looking for good excuse to play around with Sinatra. So, “with a one, and-a-two, and-a-three…” we have Sinatra-Tailer.
You can read all about it on the github page, but in short it simply performs a tail and displays the last X lines of the log file.
tail -n /path/to/my/log/file.log
- refreshes the list every X seconds, set by the user
- only one config.yml file to edit
- supports file globs, so you can grab a whole list of file with one line
- specify the number of lines to show
- completely unobtrusive js, because I’m cool?
- (tested on 0.9.1.1, earlier may work)
I whipped this up pretty quickly so I’m sure there are a few bugs. There is some testing for a few unit tests, but nothing functional.
One word of warning, if you want to put this on a production server my recommendation is to put it on a separate port (like 9876) and for heaven’s sake, at a minimum use http basic authentication. From the sinatra readme:
use Rack::Auth::Basic do |username, password|
username == 'admin' &amp;&amp; password == 'secret'
[…] Daddy Fixes Everything » Blog Archive » Sinatra-Tailer: a small app for viewing server log files […]
[…] Sinatra-Tailer: a small app for viewing server log files keep an eye on on our servers… log files. Oh, and I was looking for good excuse to play around with Sinatra. So, “with a one, and-a-two, and-a-three…” we have Sinatra-Tailer. […]
I had pretty much only been using passenger, not rackup. I made some changes to the repo so that you can start it with ‘ruby rack_logs.rb’ or ‘rackup config.ru’ or use passenger. Pull or clone the latest and let me know if that works.