当我试图运行一个 ruby 应用程序时,它给出了以下错误,
谁能给它一些启示。
ruby logger.rb
/home/swapnasa/Downloads/irclogger-master
logger.rb:14:in `read': No such file or directory - ./tmp/logger.pid (Errno::ENOENT)
from logger.rb:14:in `<main>'
代码在这里:
#!/usr/bin/env ruby
puts Dir.pwd
$: << File.join(File.dirname(__FILE__), 'lib')
require 'irclogger'
require 'irclogger/cinch_plugin'
require 'redis'
pidfile = File.join(File.dirname(__FILE__), 'tmp', 'logger.pid')
begin
old_pid = File.read(pidfile).to_i
Process.kill 0, old_pid
raise "An existing logger process is running with pid #{old_pid}. Refusing to start"
rescue Errno::ESRCH
end
File.open(pidfile, 'w') do |f|
f.write Process.pid
end
bot = Cinch::Bot.new do
configure do |c|
c.server = Config['server']
c.channels = Config['channels']
c.user = Config['username']
c.nick = Config['nickname']
c.realname = Config['realname']
# cinch, oh god why?!
c.plugins.plugins = [IrcLogger::CinchPlugin]
end
end
IrcLogger::CinchPlugin.redis = Redis.new(url: Config['redis'])
bot.start