Skip to content

Commit c45cb2d

Browse files
author
Richard Jones
committed
allow use of roundup-server pidfile without forking [SF#1614753]
1 parent c4d896e commit c45cb2d

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Fixed:
1515
- HTMLClass fixed to work with new item permissions check (sf bug 1602983)
1616
- support POP over SSL (sf patch 1597703)
1717
- clean up input field generation and quoting of values (sf bug 1615616)
18+
- allow use of roundup-server pidfile without forking (sf bug 1614753)
1819

1920

2021
2006-11-11 1.3.1

roundup/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Roundup Issue Tracker configuration support
22
#
3-
# $Id: configuration.py,v 1.37 2006-12-11 23:36:15 richard Exp $
3+
# $Id: configuration.py,v 1.38 2006-12-18 03:53:39 richard Exp $
44
#
55
__docformat__ = "restructuredtext"
66

@@ -482,6 +482,8 @@ def str2value(self, value):
482482
(TimezoneOption, "timezone", "UTC", "Default timezone offset,"
483483
" applied when user's timezone is not set.",
484484
["DEFAULT_TIMEZONE"]),
485+
(BooleanOption, "nodaemon", "no",
486+
"don't fork (this overrides the pidfile automatism).'"),
485487
(BooleanOption, "instant_registration", "no",
486488
"Register new users instantly, or require confirmation via\n"
487489
"email?"),

roundup/scripts/roundup_server.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
"""Command-line script that runs a server over roundup.cgi.client.
1919
20-
$Id: roundup_server.py,v 1.85 2006-11-09 00:36:21 richard Exp $
20+
$Id: roundup_server.py,v 1.86 2006-12-18 03:53:39 richard Exp $
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

@@ -378,6 +378,8 @@ class ServerConfig(configuration.Config):
378378
"In order to use this option, "
379379
"the server must be run initially as root.\n"
380380
"Availability: Unix."),
381+
(configuration.BooleanOption, "nodaemon", "no",
382+
"don't fork (this overrides the pidfile mechanism)'"),
381383
(configuration.BooleanOption, "log_hostnames", "no",
382384
"Log client machine names instead of IP addresses "
383385
"(much slower)"),
@@ -408,6 +410,7 @@ class ServerConfig(configuration.Config):
408410
"user": "u:",
409411
"logfile": "l:",
410412
"pidfile": "d:",
413+
"nodaemon": "D",
411414
"log_hostnames": "N",
412415
"multiprocess": "t:",
413416
}
@@ -638,6 +641,14 @@ def usage(message=''):
638641
}
639642

640643

644+
def writepidfile(pidfile):
645+
''' Write a pidfile (only). Do not daemonize. '''
646+
pid = os.getpid()
647+
if pid:
648+
pidfile = open(pidfile, 'w')
649+
pidfile.write(str(pid))
650+
pidfile.close()
651+
641652
def daemonize(pidfile):
642653
''' Turn this process into a daemon.
643654
- make sure the sys.std(in|out|err) are completely cut off
@@ -763,7 +774,10 @@ def run(port=undefined, success_message=None):
763774
" on this Operating System")
764775
sys.exit(0)
765776
else:
766-
daemonize(config["PIDFILE"])
777+
if config['NODAEMON']:
778+
writepidfile(config["PIDFILE"])
779+
else:
780+
daemonize(config["PIDFILE"])
767781

768782
# create the server
769783
httpd = config.get_server()

0 commit comments

Comments
 (0)