From: Jason H. <ja...@pe...> - 2002-01-17 19:04:12
|
On Thu, 2002-01-17 at 12:54, Roger wrote: > While debugging a silly mistake, I discovered a convenient way to reload > my SitePage to incorporate coding changes during my testing. I also find OneShot.cgi to be too slow for testing, perhaps because I have a relatively slow machine. In any case, I modified WebKit.cgi (which is run on every request) to first look for changes in my source tree, and restart the appserver if there were any changes made. That way I have a delay on the first request after making a change, but for subsequent pages it's almost as fast as WebKit. I had to allow the www-data user (under which cgi runs on my machine) write permissions to my app directory, so that it can create a timestamp and write to the log file. Here's the source, hope it's useful: #!/usr/bin/env python # If the Webware installation is located somewhere else, # then set the WebwareDir variable to point to it. # For example, WebwareDir = '/Servers/Webware' WebwareDir = '/home/jdhildeb/projects/Webware' # If you used the MakeAppWorkDir.py script to make a separate # application working directory, specify it here. AppWorkDir = '/home/jdhildeb/projects/mobile/app' try: import os, sys # mod starts here file = os.popen("cd %s ; find . -name '*.py' -newer timestamp" % ( AppWorkDir ) , "r" ) output = file.readlines() file.close() if len(output) > 0: os.system("cd %s; kill `cat appserverpid.txt` ; touch timestamp; sleep 1 ; ./AppServer &>appserver.log &" % AppWorkDir ) # mod ends here if WebwareDir: sys.path.insert(1, WebwareDir) else: WebwareDir = os.path.dirname(os.getcwd()) webKitDir = os.path.join(WebwareDir, 'WebKit') if AppWorkDir is None: AppWorkDir = webKitDir else: sys.path.insert(1, AppWorkDir) import WebKit.CGIAdapter WebKit.CGIAdapter.main(AppWorkDir) except: import string, sys, traceback from time import asctime, localtime, time sys.stderr.write('[%s] [error] WebKit: Error in adapter\n' % asctime(localtime(time()))) sys.stderr.write('Error while executing script\n') traceback.print_exc(file=sys.stderr) output = apply(traceback.format_exception, sys.exc_info()) output = string.join(output, '') output = string.replace(output, '&', '&') output = string.replace(output, '<', '<') output = string.replace(output, '>', '>') output = string.replace(output, '"', '"') sys.stdout.write('''Content-type: text/html <html><body> <p>ERROR <p><pre>%s</pre> </body></html>\n''' % output) |