Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 读取文件-enoint时出错:没有这样的文件或目录@rb_sysopen_Ruby_Dashing - Fatal编程技术网

Ruby 读取文件-enoint时出错:没有这样的文件或目录@rb_sysopen

Ruby 读取文件-enoint时出错:没有这样的文件或目录@rb_sysopen,ruby,dashing,Ruby,Dashing,我刚开始探索扣杀(以前称为冲刺) 根据这里的url 我试图做的只是从本地文件简单读取 本地文件位于名为googlestatus的其他目录中,它包含: connected jobs/ops.orb包含: gstatus = puts File.read(./status/googlestatus) ############ scheduler SCHEDULER.every '1s', :first_in => 0 do |job| send_event('response_time

我刚开始探索扣杀(以前称为冲刺)

根据这里的url

我试图做的只是从本地文件简单读取

本地文件位于名为googlestatus的其他目录中,它包含:

connected
jobs/ops.orb包含:

gstatus = puts File.read(./status/googlestatus)

############ scheduler
SCHEDULER.every '1s', :first_in => 0 do |job|
  send_event('response_time', { value: gstatus })
end
但当我运行smashing start时,它给了我以下错误:

Arrived
bundler: failed to load command: thin (/usr/local/bin/thin)
Errno::ENOENT: No such file or directory @ rb_sysopen - googlestatus
  /home/test/monitorama/monitorama/jobs/test-r.rb:3:in `initialize'
  /home/test/monitorama/monitorama/jobs/test-r.rb:3:in `open'
  /home/test/monitorama/monitorama/jobs/test-r.rb:3:in `get_file_as_string'
  /home/test/monitorama/monitorama/jobs/test-r.rb:12:in `<top (required)>'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:170:in `require'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:170:in `block in require_glob'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:169:in `each'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:169:in `require_glob'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:180:in `<top (required)>'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing.rb:3:in `require'
  /var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing.rb:3:in `<top (required)>'
  config.ru:1:in `require'
  config.ru:1:in `block in <main>'
  /var/lib/gems/2.7.0/gems/rack-2.2.2/lib/rack/builder.rb:125:in `instance_eval'
  /var/lib/gems/2.7.0/gems/rack-2.2.2/lib/rack/builder.rb:125:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in `eval'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in `load'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/controllers/controller.rb:72:in `start'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/runner.rb:203:in `run_command'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/runner.rb:159:in `run!'
  /var/lib/gems/2.7.0/gems/thin-1.7.2/bin/thin:6:in `<top (required)>'
  /usr/local/bin/thin:23:in `load'
  /usr/local/bin/thin:23:in `<top (required)>'
到达
绑定器:无法加载命令:thin(/usr/local/bin/thin)
Errno::enoint:没有这样的文件或目录@rb_sysopen-googlestatus
/home/test/monitorama/monitorama/jobs/test-r.rb:3:in'initialize'
/home/test/monitorama/monitorama/jobs/test-r.rb:3:处于“打开”状态
/home/test/monitorama/monitorama/jobs/test-r.rb:3:in'get_file_as_string'
/home/test/monitorama/monitorama/jobs/test-r.rb:12:in`'
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:170:在'require'中
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:170:“请求中的块”
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:169:in'each'
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:169:in“require_glob”
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing/app.rb:180:in`'
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing.rb:3:in'require'
/var/lib/gems/2.7.0/gems/smashing-1.3.0/lib/dashing.rb:3:in`'
config.ru:1:in'require'
config.ru:1:in'block in'
/var/lib/gems/2.7.0/gems/rack-2.2.2/lib/rack/builder.rb:125:in'instance_eval'
/var/lib/gems/2.7.0/gems/rack-2.2.2/lib/rack/builder.rb:125:in'initialize'
config.ru:1:in'new'
config.ru:1:in`'
/var/lib/gems/2.7.0/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in'eval'
/var/lib/gems/2.7.0/gems/thin-1.7.2/lib/rack/adapter/loader.rb:33:in'load'
/var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/controllers/controller.rb:182:in'load\u rackup\u config'
/var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/controllers/controller.rb:72:in'start'
/var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/runner.rb:203:in'run_命令'
/var/lib/gems/2.7.0/gems/thin-1.7.2/lib/thin/runner.rb:159:in'run!'
/var/lib/gems/2.7.0/gems/thin-1.7.2/bin/thin:6:in`'
/usr/local/bin/thin:23:在“加载”中
/usr/local/bin/thin:23:in`'

您的代码有两个问题:

  • 您需要在代码中用引号括起文件名,即:
    puts File.read("./status/googlestatus")
    
  • 现在,您正在(尝试)在启动期间只读取文件内容一次。它的一次读取值将每秒发送一次,而不会再次读取。您可能希望将文件的读取放入计划块中
  • 最后,您试图读取的文件在启动期间似乎不存在