Phrogz
Phrogz

Reputation: 303224

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.

Upvotes: 1

Views: 117

Answers (1)

Mewp
Mewp

Reputation: 4715

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.

Upvotes: 3

Related Questions