comparison roundup/scripts/roundup_server.py @ 1868:1545a36ae887

Use roundup_server script in demo.py to reduce duplication (first part of fixing [SF##798659]).
author Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
date Sat, 25 Oct 2003 11:41:06 +0000
parents 9b100d7bcb80
children db97431125a5
comparison
equal deleted inserted replaced
1867:9b100d7bcb80 1868:1545a36ae887
14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
16 # 16 #
17 """ HTTP Server that serves roundup. 17 """ HTTP Server that serves roundup.
18 18
19 $Id: roundup_server.py,v 1.30 2003-10-25 11:20:17 jlgijsbers Exp $ 19 $Id: roundup_server.py,v 1.31 2003-10-25 11:41:06 jlgijsbers Exp $
20 """ 20 """
21 21
22 # python version check 22 # python version check
23 from roundup import version_check 23 from roundup import version_check
24 24
261 devnull = os.open('/dev/null', 0) 261 devnull = os.open('/dev/null', 0)
262 os.dup2(devnull, 0) 262 os.dup2(devnull, 0)
263 os.dup2(devnull, 1) 263 os.dup2(devnull, 1)
264 os.dup2(devnull, 2) 264 os.dup2(devnull, 2)
265 265
266 def run(): 266 def run(port=8080, success_message=None):
267 ''' Script entry point - handle args and figure out what to to. 267 ''' Script entry point - handle args and figure out what to to.
268 ''' 268 '''
269 # time out after a minute if we can 269 # time out after a minute if we can
270 import socket 270 import socket
271 if hasattr(socket, 'setdefaulttimeout'): 271 if hasattr(socket, 'setdefaulttimeout'):
272 socket.setdefaulttimeout(60) 272 socket.setdefaulttimeout(60)
273 273
274 hostname = '' 274 hostname = ''
275 port = 8080
276 pidfile = None 275 pidfile = None
277 logfile = None 276 logfile = None
278 try: 277 try:
279 # handle the command-line args 278 # handle the command-line args
280 try: 279 try:
366 # redirect stdout/stderr to our logfile 365 # redirect stdout/stderr to our logfile
367 if logfile: 366 if logfile:
368 # appending, unbuffered 367 # appending, unbuffered
369 sys.stdout = sys.stderr = open(logfile, 'a', 0) 368 sys.stdout = sys.stderr = open(logfile, 'a', 0)
370 369
371 print _('Roundup server started on %(address)s')%locals() 370 if success_message:
371 print success_message
372 else:
373 print _('Roundup server started on %(address)s')%locals()
374
372 try: 375 try:
373 httpd.serve_forever() 376 httpd.serve_forever()
374 except KeyboardInterrupt: 377 except KeyboardInterrupt:
375 print 'Keyboard Interrupt: exiting' 378 print 'Keyboard Interrupt: exiting'
376 379

Roundup Issue Tracker: http://roundup-tracker.org/