开发者

Mercurial - keeping deployed and development repositories

I am working on a PHP website where I have just added a switch for what environment it is running in - development f开发者_开发问答or when it is running on my local site, and production when it is running live on the web host:

<?php
define('ENV','development');
//or
define('ENV','production');

I have the site under VC with Mercurial, and usually simply deploy my site with hg push (the server runs hg too), however, with the addition of this switch, the "production" site will always differ from the "development" site in that the version deployed live will always be set to production instead of development.

This means my deployment process goes from

  1. Develop
  2. Test
  3. hg commit -m "Made changes"
  4. hg push
  5. ssh host hg update
  6. Go to 1.

to

  1. Develop
  2. Test
  3. hg commit -m "Made changes"
  4. Change development to production
  5. `hg commit -m "dev -> prod"
  6. hg push
  7. ssh host hg update
  8. (later:) Change production -> development
  9. hg commit -m "prod -> dev"
  10. Go to 1.

Which is obviously not great.

Is there some way to keep one insulated from the other, so that the live site will always be set to production and my local copy set to development?


Instead of having a switch, have a development branch and a production branch.

hg up prodbranch 
hg merge -r devbranch
hg push
ssh yourserver hg update prodbranch


If you have an Apache webserver, you could just set this in server/vhost/per-directory/.htaccess config:

SetEnv Deployment development

Or in production

SetEnv Deployment production

And in your script use:

define('ENV',$_ENV['Deployment'])

I assume (as it usually is) that the actual webserver / virtualhost config is outside the normal code.

http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv


Have you thought about just not putting your conifguration file under version control?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜