首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Thin & Sinatra不进港

Thin & Sinatra不进港
EN

Stack Overflow用户
提问于 2012-03-28 11:26:20
回答 1查看 2K关注 0票数 3

我在使用Thin和Sinatra设置我的应用程序时遇到了问题。我已经创建了一个开发-config.ru文件,它包含以下设置:

代码语言:javascript
运行
复制
# This is a rack configuration file to fire up the Sinatra application.
# This allows better control and configuration as we are using the modular
# approach here for controlling our application.
#
# Extend the Ruby load path with the root of the API and the lib folder
# so that we can automatically include all our own custom classes. This makes
# the requiring of files a bit cleaner and easier to maintain.
# This is basically what rails does as well.
# We also store the root of the API in the ENV settings to ensure we have
# always access to the root of the API when building paths.
ENV['API_ROOT'] = File.dirname(__FILE__)
$:.unshift ENV['API_ROOT']
$:.unshift File.expand_path(File.join(ENV['API_ROOT'], 'lib'))
$:.unshift File.expand_path(File.join(ENV['API_ROOT'], 'db'))

# Now we can require all the gems used for the entire API by simpling requiring
# them here. We can also include the classes that we have defined inside the lib
# folder.
require 'rubygems'
require 'bundler'

# Run Bundler to setup our gems properly. This will install  all the missing gems on
# the system and ensure that the deployment environment is ready to run.
Bundler.require

# To make the loading easier for the application, we will now automatically load all
# models that have been defined inside the lib folder. This ensures that we do not need
# to load them anymore anywhere else in our application, as the models will be known to
# ruby everywhere.
Dir.glob(File.join(ENV['API_ROOT'], 'lib', '**', '*.rb')).each{|file| require file}

# Now we will configure the Sinatra application so that we can fire up the entire API.
# This requires some detailed settings like whether logging is allowed, the port to be
# used and some folder locations.
require 'sinatra'
require 'app'
set :logging, true
set :dump_errors, true
set :port, 3001
set :views, "#{ENV['API_ROOT']}/views"
set :public_folder, "#{ENV['API_ROOT']}/public"
set :environment, :test

# Start up the Sinatra application with all the settings that we have defined.
run App.new

这是基于我在西纳特拉网站上找到的信息。但是,问题是我无法让应用程序在端口3001上运行。如果我使用thin start -R development config.ru,它将运行在端口3000上。如果我使用rackup config-development.ru,它将运行在端口9696上。然而,我从来没有看到辛纳屈踢进或跑过3000端口。

我的应用程序如下所示:

代码语言:javascript
运行
复制
# Author : Arne De Herdt
# Email : 
# This is the actuall application that will be running under Sinatra
# to serve the requests for the billing middleware API.
# We use the modular approach here to allow control when deploying
# the application using Capistrano.
require 'sinatra/base'
require 'logger'
require 'savon'
require 'billcrux'

class App < Sinatra::Base
  # This action responds to POST requests on the URI '/billcrux/register'
  # and is responsible for handeling registration requests with the
  # BillCrux payment system.
  # The
  post "/billcrux/register" do
    # do stuff
  end
end

有人能告诉我我做错了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-28 11:40:49

找到了解决办法。

代码语言:javascript
运行
复制
Rack::Handler::Thin.run App.new, :Port => 3001

而不是

代码语言:javascript
运行
复制
run App.new
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9906509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档