Yii Framework Forum: Deployment automation - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Deployment automation Rate Topic: -----

#1 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 17 February 2010 - 05:58 PM

This is one of those things that I know all the experiences web developers do but I haven't taken the time to figure it out yet. I think it's time.

What techniques do you guys use for deploying (or updating) your applications to external web hosts?

This is what I have always done, which pretty much sucks:

1. SVN Commit via TortoiseSVN (~6 seconds of clicking around)
2. SVN Export via TortoiseSVN (~15 seconds of clicking around)
3. Open FileZilla (3 seconds)
4. Upload exported files, with "Export if source newer" option (10 seconds)

This all adds up to a half a minute. Sometimes I do this 10 times a day. I hate doing it. I don't even take the site down usually when performing the update. Not good

It seems I could create a script to automate all of this, so all I have to do is run it and *bam* the site updates to my local copy.

I am looking for advice for the best way to set this up. I've done some googling and it seems there are a whole bunch of options, so many I don't know where to start.

What I would like:
1. Only changed or new files should be uploaded to the server, that are under version control. No need to re-upload the whole thing each time
2. Scripts to take down and up the site to run before doing maintenance (could be as simple as uploading an alternate index.php file).

What I think I need:
1. FTP software that can be run from command line (what is good?)
2. Figure out how to use version control from command line

What methods have you guys gone about? Any examples out there? It seems the script could be written in pretty much any language including php.

I am using windows. It seems that most examples on the web are directed towards linux which I really don't know much about.

I'm going to play around but I was wondering if anyone had any starting advice before I try something out which turns out to be a bad method

Thanks,
Jonah
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 17 February 2010 - 06:04 PM

We are using "svn update" to deploy. It usually happens that you may find bugs or add new features after the system is deployed for the first time. Then you will appreciate how convenient "svn update" is. To make it safer, you could use svn branches to make sure you only "svn update" on the production server when you think the code is stable enough.
0

#3 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 17 February 2010 - 06:46 PM

Ah yes this solution did cross my mind. Is this possible on a shared host however?

Just did some googling and it seems to get it working I first need to learn how to connect to the server with SSH. So it is possible. So I'm going to do some playing around with that. You pointed me in the right direction. Thanks!

EDIT: just got putty/ssh working on dreamhost. This is cool stuff.. svn is already installed

EDIT2: OK it seems like its gonna work on my other host too. This is gonna save a lot of time
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#4 User is offline   sAe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 18-May 09
  • Location:Sweden, Karlstad

Posted 23 February 2010 - 02:58 PM

We're using Git for versioning, since we have all our servers mounted as remoted drives (through ssh/sftp)
we just copy the files over. To make sure noone is really browsing your site during that time you update the site,
just replace your index.php with a temporary one telling the user you are updating the sitechanges, then replace
your index.php with the new/old one.

That way you can make sure no user makes any database calls or other updates on your site that potentionally could
mess something up.

To update the database (MySQL) we usually use the synchronization tool in MySQL Workbench, if there's nothing that
potentionally could mess up data we just push the changes otherwise we would have to make some script to convert the
data/temporarily move it or whatever suits the changes. :)

I really recommend MySQL Workbench if you are not using it already, got all those nifty tools builtin and it's all free.
Also make sure to use the Beta version, the older ones are not as good.

Just one thing i came to think of when you said you use SVN, doesn't that mean you also have tons of .svn folders
in your production server that might actually expose PHP code to the user if you don't make sure to block users
from accessing them? Just a heads up to Jonah if you didn't think of it already :)
0

#5 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 23 February 2010 - 05:12 PM

I've never heard of mounting a server as a remote drive.. just googled it and it sounds pretty nifty/cool. I like using svn update as apposed to copying the files over as it takes less time for the server to do, as it only sends the file changes.

I just checked if the .svn folders were accessible and luckily they are not (for whatever reason).

I use plink (command line version of putty) to deploy the application via a .bat file (one click!). I am also planing on creating .bat files to bring up and down the server for public use (by replacing index.php probably).

I hear git has a lot of improvements over svn so I hope to learn it someday when I have time..

For updating the database, I have always just done it manually on the server phpMyAdmin script. Not the cleanest method.. Whenever I made a change on my local database for testing, I would just jot down the sql that phpMyAdmin executed, then executed the same thing on the remote server phpMyAdmin once deploying. Haven't needed to convert any data yet. So I'm going to try out this MySQL Workbench and see what it's about..
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#6 User is offline   thyseus 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 300
  • Joined: 18-April 09
  • Location:Leipzig, Germany

Posted 23 February 2010 - 05:45 PM

I know, that everyone is knowing it, but i want to mention rsync for every non-svn/git/googlecode project around. Initial sync takes long (since it copies up ALL data) but after that, only the changes are 'commited' which makes it very fast ( way < 1 second )...
0

#7 User is offline   creocoder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 198
  • Joined: 09-March 09
  • Location:*.php

Posted 02 March 2010 - 06:02 AM

to jonah

Quote

For updating the database, I have always just done it manually on the server phpMyAdmin script. ... So I'm going to try out this MySQL Workbench and see what it's about..

Look at SQLyog (Webyog Softworks). 2 Powertools there: DataBase Synchronization Wizard and Schema Synchronization Tool.
No good, no bad, only consequence.
0

#8 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 02 March 2010 - 12:40 PM

The beta of MySQL workbench seems to have a lot of bugs right now. For instance, after altering a table, the changes don't show until I refresh my object explorer, and when I do that, I have to re-navigate to where I was. Besides the bugs it's perty good tho

gonna take a look at SQLyog
http://php-thoughts.cubedwater.com - my bloggings about Yii
0

#9 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 02 March 2010 - 12:55 PM

On all of my past projects I simply uploaded new/updated files via FTP without putting site offline or something. It worked well since the overall amount of files were always small. I'm looking forward to use a version control system to do the updates of new projects.

You guys know if there's an offline svn/git/bazaar solution (maybe a bundle with webserver or something)? Because for now I work alone but I would still like to use versioning and then later put everything online so others can access.
0

#10 User is offline   sAe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 18-May 09
  • Location:Sweden, Karlstad

Posted 15 March 2010 - 02:00 PM

View PostY!!, on 02 March 2010 - 12:55 PM, said:

On all of my past projects I simply uploaded new/updated files via FTP without putting site offline or something. It worked well since the overall amount of files were always small. I'm looking forward to use a version control system to do the updates of new projects.

You guys know if there's an offline svn/git/bazaar solution (maybe a bundle with webserver or something)? Because for now I work alone but I would still like to use versioning and then later put everything online so others can access.


Well that's the good thing about Git, it is local, you can do as many commits you wish locally before you push it to your server (if you do push it to a server).
0

#11 User is offline   sAe 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 18-May 09
  • Location:Sweden, Karlstad

Posted 15 March 2010 - 02:02 PM

View Postjonah, on 23 February 2010 - 05:12 PM, said:

I've never heard of mounting a server as a remote drive.. just googled it and it sounds pretty nifty/cool. I like using svn update as apposed to copying the files over as it takes less time for the server to do, as it only sends the file changes.

I just checked if the .svn folders were accessible and luckily they are not (for whatever reason).

I use plink (command line version of putty) to deploy the application via a .bat file (one click!). I am also planing on creating .bat files to bring up and down the server for public use (by replacing index.php probably).

I hear git has a lot of improvements over svn so I hope to learn it someday when I have time..

For updating the database, I have always just done it manually on the server phpMyAdmin script. Not the cleanest method.. Whenever I made a change on my local database for testing, I would just jot down the sql that phpMyAdmin executed, then executed the same thing on the remote server phpMyAdmin once deploying. Haven't needed to convert any data yet. So I'm going to try out this MySQL Workbench and see what it's about..


Git is very similar to SVN in usage, it took me about 5min to learn how to use it, really :)
It's even simpler if you use a GUI tool for it aswell. I however prefer my terminal if i dont want to check code diffs that is.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users