机架服务器无法启动

机架服务器无法启动

我是 ruby​​ 和 rack 的初学者;尝试启动 rack 服务器,但rackup config.ru命令没有任何反应。

现在我的 rackup 文件是

#!/usr/bin/env ruby

require "rack"
Rack::Server.start

并且,config.ru 文件是

require "#{File.dirname(__FILE__)}/../testrequest"

$stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")

class EnvMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    # provides a way to test that lint is present
    if env["PATH_INFO"] == "/broken_lint"
      return [200, {}, ["Broken Lint"]]
    # provides a way to kill the process without knowing the pid
    elsif env["PATH_INFO"] == "/die"
      exit!
    end

    env["test.$DEBUG"]      = $DEBUG
    env["test.$EVAL"]       = BUKKIT if defined?(BUKKIT)
    env["test.$VERBOSE"]    = $VERBOSE
    env["test.$LOAD_PATH"]  = $LOAD_PATH
    env["test.stderr"]      = File.expand_path($stderr.path)
    env["test.Ping"]        = defined?(Ping)
    env["test.pid"]         = Process.pid
    @app.call(env)
  end
end

use EnvMiddleware
run Rack::Server.new

我浏览了一些在线资源或问题,但都无济于事。如果有人能建议更改这些文件或做什么,我将不胜感激。

相关内容