开发者

Changing Sinatra settings on a per-machine basis

My development machine is different from my deployment/production servers in some ways that cannot be changed. (For example, my development machine has multiple versions of database servers running on different ports, while each production server has only a开发者_高级运维 single version of the RDBMS running, each instance running on the default port.)

What techniques are available for configuring a Sinatra web application differently on one machine versus another? Ideally, answers would summarize multiple approaches, and highlight the one approach that has worked best for the respondent. Any file-based solutions should also (ideally) discuss how to handle this situation in the presence of a unified source control repository between both machines.

Note that this question/problem is orthogonal to configuring for development mode versus production mode.


One solution would be to load two configuration files: first, the main one (let's say, settings.rb), then a machine-specific one that would override necessary settings (settings-custom.rb).

Of course, since you have multiple machines, you have multiple configuration sets. In order to manage them easily, they could be named settings-$hostname.rb. Then you could simply symlink the appropriate file to settings-custom.rb. For example, on unix:

ln -s settings-`hostname`.rb settings-custom.rb

If you use source control, you can track all the configuration sets, and ignore settings-custom.rb (because it's only a symlink, and doesn't need to be tracked) -- with this method, you won't need to change any code between the machines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜