public
Description: Personal twitter jabber bot
Homepage: http://github.com/blaxter/rtwittbot
Clone URL: git://github.com/blaxter/rtwittbot.git
rtwittbot / bin / rtwittbotd
100755 30 lines (23 sloc) 0.638 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
 
APP_NAME = 'rtwittbot'
 
def daemon_for(app_name, script)
    base = if File.symlink? __FILE__
        File.readlink __FILE__
    else
        __FILE__
    end
 
    begin
        Dir.mkdir File.expand_path("~/.#{app_name}")
    rescue Errno::EEXIST
        # all ok, already exists
    end
 
    daemon = "#{File.dirname base}/#{script}"
    options = { :app_name => app_name,
                :dir_mode => :normal,
                :dir => "~/.#{app_name}",
                :log_output => true }
 
    Daemons.run daemon, options
end
 
daemon_for(APP_NAME, 'rtwittbot.rb')