You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Tom Lancaster <to...@2071.org> on 2006/06/29 21:06:09 UTC

Local vs Live Config for sites without root control

Hello,

I'm sure this must have been discussed before, but I obviously haven't 
found the right keywords to search for.

On one of my projects I am using separate config files for the web 
project which check what the name of the server is. I would like to know 
if it is possible to make a hook into svn to avoid having to do this.

For example if I make a release, can that prompt a change in certain 
files while leaving the development copies the same?

I only ask because I would rather not have my live code constantly 
checking what server it is running on.

Thank you in advance, and apologies if this is an obvious question.

Regards,

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Local vs Live Config for sites without root control

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jun 30, 2006, at 00:10, Tom Lancaster wrote:

> Ryan Schmidt wrote:
>
>> I do this in my sites:
>> <?php
>> if (LIVE_SERVER) {
>>     define('DB_HOST', 'dbserver');
>>     define('DB_USER', 'foo');
>>     define('DB_PASS', 'bar');
>> } else {
>>     define('DB_HOST', 'localhost');
>>     define('DB_USER', 'root');
>>     define('DB_PASS', '');
>> }
>> ?>
>> And the LIVE_SERVER constant is defined to true only on the  
>> development server.
>
> Thank you. I do this also, I'm just wondering if there's a fancy  
> way to keep live and dev config files under version control as the  
> same file.
>
> Granted it's a minor problem, but it's happened more than once that  
> I uploaded my local config file to a staging server which had no  
> idea about some non-existent domain.
>
> I think ignore-commit is not perfect, because I want certain  
> changes to config files to propagate. I also want other changes to  
> propagate, and I certainly want version control on said files.
>
> Probably what I'm asking for is advanced regex hooks into svn  
> exports ( when I'm ready to go live I should export, right??? )

I happen to do an export, yes. You don't want your web visitors to be  
able to dive into the .svn directory and retrieve your source code  
from the text base. But you can also easily configure Apache to deny  
access to those directories even if they're there. This does it:

RedirectMatch 404 .*/\.svn(/|$)

Makes it look like they were never even there. The reason I still do  
an export as that a working copy update is not atomic -- there could  
be a network problem and the update would abort, leaving the working  
copy in a half-updated state in which the site might not function.  
Therefore I update a working copy, and when it's done, I export that  
to a new directory, and then I change a symlink to point to the new  
export, and the web server's virtual host only has to point to the  
symlink.

In the script we use to deploy our releases to our production server,  
there's an option to have it run some other script after the export  
is done. You could do something like that: have a script which you  
run to deploy the live site, which not only fetches the latest  
version from the repository but also fiddles with the config files.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Local vs Live Config for sites without root control

Posted by Tom Lancaster <to...@2071.org>.
Ryan Schmidt wrote:

> I do this in my sites:
> 
> <?php
> if (LIVE_SERVER) {
>     define('DB_HOST', 'dbserver');
>     define('DB_USER', 'foo');
>     define('DB_PASS', 'bar');
> } else {
>     define('DB_HOST', 'localhost');
>     define('DB_USER', 'root');
>     define('DB_PASS', '');
> }
> ?>
> 
> And the LI, and IVE_SERVER constant is defined to true only on the development 
> server.
> 

Thank you. I do this also, I'm just wondering if there's a fancy way to 
keep live and dev config files under version control as the same file.

Granted it's a minor problem, but it's happened more than once that I 
uploaded my local config file to a staging server which had no idea 
about some non-existent domain.

I think ignore-commit is not perfect, because I want certain changes to 
config files to propagate. I also want other changes to propagate, and I 
certainly want version control on said files.

Probably what I'm asking for is advanced regex hooks into svn exports ( 
when I'm ready to go live I should export, right??? )

Any advice on best practices here is very much appreciated.

Again, TIA,

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Local vs Live Config for sites without root control

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jun 29, 2006, at 23:06, Tom Lancaster wrote:

> I'm sure this must have been discussed before, but I obviously  
> haven't found the right keywords to search for.
>
> On one of my projects I am using separate config files for the web  
> project which check what the name of the server is. I would like to  
> know if it is possible to make a hook into svn to avoid having to  
> do this.
>
> For example if I make a release, can that prompt a change in  
> certain files while leaving the development copies the same?
>
> I only ask because I would rather not have my live code constantly  
> checking what server it is running on.

I do this in my sites:

<?php
if (LIVE_SERVER) {
	define('DB_HOST', 'dbserver');
	define('DB_USER', 'foo');
	define('DB_PASS', 'bar');
} else {
	define('DB_HOST', 'localhost');
	define('DB_USER', 'root');
	define('DB_PASS', '');
}
?>

And the LIVE_SERVER constant is defined to true only on the  
development server.

If you wanted to avoid such a check, one alternative would be this way:

http://subversion.tigris.org/faq.html#ignore-commit

The PHP code could be:

require_once('config.local.php');

where config.local.php is a file that's not in your repository (in  
fact you'd probably add it to the svn:ignore list of the directory  
it's in) but must be configured in each working copy. Though I think  
checking whether a constant is true or false would be faster than  
reading in a whole 'nother file.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org