Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Experiments / Generator / Generators / Project / Templates / script / server.boo
blob906afb4a67b5c6bcbceffb2230038d087008aa29
1 import System
2 import System.IO
3 import System.Threading
4 import System.Diagnostics
6 # The command to launch the web server
7 SERVER_CMD = argv[0]
8 # Determine if the web server has to be restarted
9 # afther a built
10 SERVER_RESTART = argv[1] == 'restart'
11 # Arguments to send to with the server command
12 SERVER_ARGUMENTS = join(argv[2:], ' ')
14 # Arguments to send to nant when building
15 # Typically the target that builds and some arguments
16 NANT_ARGUMENTS = 'build -nologo -q'
18 # Time to wait before watching for changes again
19 REBUILD_DELAY = 1000 #ms
22 ######## Stop editing here unless you're a damn cool Boo hacker ########
23 watcher = FileSystemWatcher(Directory.GetCurrentDirectory(), "*.cs")
24 watcher.IncludeSubdirectories = true
25 print "Starting live server process, hit CTRL+C to stop"
27 serverProcess as Process
28 rebuild = true
30 while (true):
31 print "nant ${NANT_ARGUMENTS}"
32 buildProcess = shellp('nant', NANT_ARGUMENTS)
33 buildProcess.WaitForExit()
34 rebuild = false
36 if (buildProcess.ExitCode == 0):
37 if SERVER_RESTART or serverProcess == null:
38 # Try to stop the server
39 if (serverProcess != null):
40 try:
41 serverProcess.Kill()
42 except e:
43 pass
44 serverProcess.WaitForExit()
45 # Starts the server
46 print "${SERVER_CMD} ${SERVER_ARGUMENTS}"
47 serverProcess = shellp(SERVER_CMD, SERVER_ARGUMENTS)
48 else:
49 print "Build failed! Errors:"
50 print '=' * 80
51 print buildProcess.StandardOutput.ReadToEnd()
52 print '=' * 80
54 Thread.CurrentThread.Sleep(REBUILD_DELAY)
55 change = watcher.WaitForChanged(WatcherChangeTypes.All)
56 print "File change detected (${change.Name})"