Author: remi
Date: 2009-03-12 21:00:15 +0100 (Thu, 12 Mar 2009)
New Revision: 4028
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/TDSHTTPServer.py
software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py
Log:
* fixed a problem with the http server socket
* added a restart function
$ sudo python tuxhttpserver.py --restart
Modified: software_suite_v2/tuxware/tuxdroidserver/trunk/TDSHTTPServer.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/TDSHTTPServer.py
2009-03-12 19:34:53 UTC (rev 4027)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/TDSHTTPServer.py
2009-03-12 20:00:15 UTC (rev 4028)
@@ -184,7 +184,7 @@
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
"""Handle requests in a separate thread.
"""
- allow_reuse_address = 0
+ #allow_reuse_address = 0
#
------------------------------------------------------------------------------
# Tux Droid Server : HTTP request handler.
Modified: software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py
2009-03-12 19:34:53 UTC (rev 4027)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/tuxhttpserver.py
2009-03-12 20:00:15 UTC (rev 4028)
@@ -17,6 +17,21 @@
from TDSConfiguration import *
+def checkServerRun():
+ import httplib
+ h = httplib.HTTP("127.0.0.1:%d" % TDS_CONF_MAJOR_PORT_ADDRESS)
+ try:
+ h.connect()
+ h.putrequest("GET", "/")
+ h.endheaders()
+ code, st, msg = h.getreply()
+ if code != 200:
+ return False
+ else:
+ return True
+ except:
+ return False
+
def killServer():
import httplib
h = httplib.HTTP("127.0.0.1:%d" % TDS_CONF_MAJOR_PORT_ADDRESS)
@@ -30,7 +45,14 @@
h.putrequest("GET", "/server/stop?")
h.endheaders()
h.getreply()
-
+
+def killServerAndWait():
+ import time
+ killServer()
+ time.sleep(1.0)
+ while checkServerRun():
+ time.sleep(1.0)
+
def runServer():
import TuxDroidServer
from TuxDroidServer import initializeServer
@@ -44,12 +66,15 @@
# Main
#
------------------------------------------------------------------------------
if __name__ == '__main__':
- mode = 'START'
if len(sys.argv) > 1:
if sys.argv[1] == "--start":
mode = 'START'
+ elif sys.argv[1] == "--restart":
+ mode = 'RESTART'
elif sys.argv[1] == "--stop":
mode = 'STOP'
+ else:
+ mode = 'START'
if mode == 'START':
if os.name == 'nt': # Windows
runServer()
@@ -58,5 +83,14 @@
tuxDroidDaemon = Daemonizer('tuxhttpserver', '/var/log', runServer,
True)
tuxDroidDaemon.start()
+ elif mode == 'RESTART':
+ killServerAndWait()
+ if os.name == 'nt': # Windows
+ runServer()
+ else: # Linux
+ from util.daemonizer import Daemonizer
+ tuxDroidDaemon = Daemonizer('tuxhttpserver', '/var/log', runServer,
+ True)
+ tuxDroidDaemon.start()
elif mode == 'STOP':
killServer()
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn