Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Mar 2002
    Location
    Sacramento, California, USA
    Posts
    509
    Thanks
    4
    Thanked 1 Time in 1 Post

    Automating a push of new code

    It appears to me that the simplest, fastest, most foolproof way to push new code to a live web site is to make sure that the files on the development site are exactly what should be pushed to the live site. Then the push becomes a two-step process: Delete All, then Copy All.

    The problem: there are always a few files that can't be the same on the development site and the live site. The most important one is robots.txt, which must say "don't index this" on the development site, and must not say that on the live site. Other possible exceptions are .htaccess, php.ini, and IDE control files, which shouldn't go to a the live server at all.

    The question: given these necessary exceptions, what is the simplest, fastest, most foolproof way to push new code?

    I thought I'd do this by writing a script for my FTP program which said, in effect, "delete everything from the server except this list of files, then upload everything except that list of files." I discovered to my distress that my FTP program (Filezilla) doesn't support scripting at all. I've found some commercial products that do, but I can't find published details; some other things I've seen on the vendors' web sites leave me uncertain whether any of them support a "delete/upload everything except" operation.

    Other developers, how do you deal with this problem?

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,188
    Thanks
    47
    Thanked 984 Times in 914 Posts
    I would upload the new code to a "new code" directory, then use cron or similar to fire off a copy process. You can write the copy process to do anything you want, you could even put the instructions in a file you upload with the code. This assumes you have some control over the web server, of course.

    cheers, Paul

    [edit] You could even do a directory rename so you can roll back in almost no time.

  3. #3
    4 Star Lounger
    Join Date
    Mar 2002
    Location
    Sacramento, California, USA
    Posts
    509
    Thanks
    4
    Thanked 1 Time in 1 Post
    > This assumes you have some control over the web server...

    Sadly, I don't. The client uses a shared server and there's no shell access. I can add this to the list of reasons for getting a dedicated server, but it will be a major change if we do it. I hope I can find another solution to use in the meantime.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    I noticed inadvertently that removing write privileges from a file also blocks replacement by FTP. I do this for some config files and then forget and then spend 20 frustrating minutes trying to figure out why my updates aren't taking... Anyway, could be a workaround to avoid unwanted overwrites for those selected files, as long as no other process needs to be able to write to them.

  5. #5
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,188
    Thanks
    47
    Thanked 984 Times in 914 Posts
    Without shell access you can still use the new directory / rename option. Rollback is always good to have.

    cheers, Paul

  6. #6
    4 Star Lounger
    Join Date
    Mar 2002
    Location
    Sacramento, California, USA
    Posts
    509
    Thanks
    4
    Thanked 1 Time in 1 Post
    Uh... that's fine for a subdirectory, but you can't rename the root directory. All of the files that the user runs have to go in the root directory, because the user isn't going to want (or remember) to enter subdirectory names in a URL.

    Moving complete sets of files between the root directory and a subdirectory would be equally effective, though, and reasonably fast. That may be the way to go, It still doesn't give me the capability to keep some files and replace others, but I could do that in a local directory, then upload.

  7. #7
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,188
    Thanks
    47
    Thanked 984 Times in 914 Posts
    The URL is just a folder located on your hard disk. Renaming the folder should do the trick - no URL change required.

    cheers, Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •