Langdon Stevenson wrote:

 
> > And scripatability. For example, I have a simple script here that
> > locates the nearest Cake app, finds an unused port and starts a
> > webserver pointed at it. Also, my concept of updating my sites
> > involve running "make release" only. No faffing with FTP for me,
> > please - I left that behind in 1998.
> 
> Interesting.  Can you explain this further?  I was just about to set up 
> FTP for my build process, but would love to ditch it too.

I've changed it to default to 8080, but you can specify a port on the
command line.

#!/usr/bin/env python

import os, sys
import tempfile
import commands

def main():
    if len(sys.argv) >= 2:
        port = int(sys.argv[1])
    else:
        port = 8080

    webroot = os.getcwd()
    search = ['src', 'app', 'webroot']
    for i in range(len(['src', 'app', 'webroot'])):
        path = os.path.join(*[webroot] + search[i:])
        if os.path.exists(path):
            webroot = path
            break

    print "(Using '%s' for server.document-root)" % webroot

    fd, config_file = tempfile.mkstemp()
    f = os.fdopen(fd, "w+b")

    print >> f, """
        server.port             = %(port)d
        server.document-root    = "%(webroot)s"

        server.modules = ( "mod_rewrite", "mod_cgi" )

        include_shell "/usr/share/lighttpd/create-mime.assign.pl"

        server.dir-listing      = "enable"
        index-file.names        = (
                         "index.php", "index.htm", "index.html" )

        cgi.assign = ( ".php" => "/usr/bin/php-cgi" )

        url.rewrite = (
            "^/((css|files|img|js|test\.php).*)" => "$0",
            "^/(.*)" => "/index.php?url=$1"
        )
    """ % { 'port' : port, 'webroot' : webroot }
    f.close()

    try:
        print "Starting lighttpd at http://localhost:%d/"; % port
        cmd = "/usr/sbin/lighttpd -D -f %s" % config_file
        status, output = commands.getstatusoutput(cmd)
        print output
    except KeyboardInterrupt:
        pass

if __name__ == "__main__":
    main()


Regarding upload, I use the bzr revision control system for my projects
and it's "push" command works well for uploading to a server.

I usually have GNU Make 'Makefiles' which reset permissions and
purge /app/tmp for me too. These are easily mastered - they are basically
shell scripts with built-in targets.

It is also possible to upload your packages as a .deb or .rpm, but I have
only tried the former.

> I will keep Ubuntu in mind, though the thought of shifting now that I
> am set up is pretty scary.

Well, Debian and Ubuntu now have the 1.1.x.x branch of CakePHP as a
package which is easy to install. I am preparing a 1.2.x.x package too,
which I will upload when I have ironed out a few problems.


/Lamby

[0] http://bazaar-vcs.org/
[1] http://packages.ubuntu.com/cakephp

-- 
 Chris Lamb, Leamington Spa, UK                          GPG: 0x634F9A20

Attachment: signature.asc
Description: PGP signature

Reply via email to