【发布时间】:2013-08-21 23:07:18
【问题描述】:
当我试图运行一个 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
【问题讨论】:
-
好像您正在尝试打开一个不存在的文件...
-
可能很傻......我做了什么来解决这个问题,我在 tmp 目录中手动创建了 logger.pid,然后重新启动了应用程序,然后它就可以工作了。
-
发现了一个错误。现在它已修复。
标签: ruby