Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tdiary server --cgiでInternal Server Error #320

Closed
machu opened this issue Jun 8, 2013 · 6 comments
Closed

tdiary server --cgiでInternal Server Error #320

machu opened this issue Jun 8, 2013 · 6 comments
Milestone

Comments

@machu
Copy link
Member

machu commented Jun 8, 2013

CGIモードで起動すると、Internal Server Errorとなる。

500 Internal Server Error

wrong number of arguments (2 for 1) (ArgumentError)

/Users/machu/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/request.rb:20:in `initialize'
/Users/machu/work/tdiary/tdiary-core/update.rb:30:in `new'
/Users/machu/work/tdiary/tdiary-core/update.rb:30:in `<main>'

TDiary::RequestはRackが有効な場合にはRack::Requestを使うようになっている。Rack::Requestは引数を1つしか受け取れないため、第2引数の @cgi を受け取れずに ArgumentError となる。

@machu
Copy link
Member Author

machu commented Jun 8, 2013

CGIモードで起動してもRackが有効になっているのは、 #299 Bundlerize の影響?
require 'tdiary' のタイミングで Gemfile 記載のライブラリ (Rack含む) が読み込まれる。

@hsbt
Copy link
Member

hsbt commented Jun 8, 2013

CGI の時も Rack を読むようにするのがよさそうです(アイデアレベル)

@machu
Copy link
Member Author

machu commented Jun 12, 2013

ちょっとやってみましたが、CGIの時もRackを使うとassetsの判定にも影響がありますね。

def theme_url
    defined?(Rack) ? 'assets' : 'theme'
end

CGI動作用のGemfileを別に用意するか、Bundler.requireをやめて手動でrequireする方向で考えてみます。

@machu machu closed this as completed in 5e752c8 Jun 12, 2013
@machu
Copy link
Member Author

machu commented Jun 12, 2013

tdiary/environment.rb の中で bundle/setupBundler.require の両方を呼んでいることが原因でした。 Bundle::setup が2回実行されることで、環境がおかしくなっていたようです。

ちゃんと追えていないのですが、この変更を加えた結果、CGIモード(TDiary::ServerWEBrick::HTTPServlet::CGIHandler 内)では Rack が無効の状態で tDiary が動いています。

@machu
Copy link
Member Author

machu commented Jun 12, 2013

…勘違いしていました。
require 'bundle/setup' を消すと、if defiled?(Bundler) 内のブロックも実行されなくなるのでダメですね。
revertします。

@machu
Copy link
Member Author

machu commented Jun 15, 2013

「CGI動作用のGemfileを別に用意する」方法で対処。

@machu machu closed this as completed Jun 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants