From: Kazuhiko <kaz...@fd...> - 2011-09-26 17:04:22
|
On 26/09/2011 01:29, SHIBATA Hiroshi wrote: >> さまざまな環境で統一的かつ透過的に「ユーザごとのディレクトリ」を指 >> 定するには、chdirが一番問題が少ないのかもなぁ、と考えを改めつつある >> ところです。カレントディレクトリはスレッドローカルなので、よほど変 >> 態な環境でもない限り問題が出そうには思えないですね。 >> >> chdirにしちゃおうか。fcgiだけじゃなくてRack環境にも影響が出るのかな? > > 「chdir でやるの案」がどういうコードになるのかわかりませんが > > - rake specの3パターン(webrick, rack, secure)が全て動く > - symlink, ラッパーファイル(debianパッケージのもの)が動く > > であれば良いと思います。 chdirでやる案というか、「起動スクリプト(のsymlinkやラッパー)があるとこ ろをユーザごとのディレクトリとみなす」という(従来の挙動と同じ)案ですよね。 で、この案であれば、このスレッドの最初の疑問にある 昔:File::open( "tdiary.conf" ) 今:File::open( "#{File.expand_path(File.dirname($PROGRAM_NAME))}/tdiary.conf" ) が、別に昔のままでいいんじゃないの? と思うわけです。 > https://github.com/tdiary/tdiary-core/commit/5eb1e6772d19f21cf73af4cd03b80945289ad8ab#tdiary/config.rb (snip) > これは tdiary.rb から Config を tdiary/config.rb に移動したので tdiary.conf だけでは > 読み込めなくなっていたのを tdiary.rb と同じ場所を明示的に指すようにする変更です。 ↑いまだに、この一つめの変更の意図が分からないのですが、すくなくとも現状 のtDiaryのコードだと、ここでのpwdは、(tdiary.confを読むコードの場所を tdiary/config.rbに移動したかどうかに関係なく)$PROGRAM_NAMEのディレクト リじゃないのでしょうか? とりあえず、第二tDiary.Netで使っている「複数日記をホストするFastCGIスク リプト」は、chdirを使うように戻しました。 かずひこ |