Commit eefc1383 authored by Jim Fulton's avatar Jim Fulton

Merged 1.47.18.1.4.1.

parent f535cae5
...@@ -547,71 +547,72 @@ if Zpid and not READ_ONLY: ...@@ -547,71 +547,72 @@ if Zpid and not READ_ONLY:
zdaemon.run(sys.argv, os.path.join(CLIENT_HOME, Zpid)) zdaemon.run(sys.argv, os.path.join(CLIENT_HOME, Zpid))
# Import logging support try:
import zLOG # Import logging support
import ZLogger import zLOG
import ZLogger
if READ_ONLY: if READ_ONLY:
zLOG._stupid_dest=sys.stderr zLOG._stupid_dest=sys.stderr
else: else:
zLOG.log_write = ZLogger.ZLogger.log_write zLOG.log_write = ZLogger.ZLogger.log_write
if DETAILED_LOG_FILE: if DETAILED_LOG_FILE:
from ZServer import DebugLogger from ZServer import DebugLogger
logfile=os.path.join(CLIENT_HOME, DETAILED_LOG_FILE) logfile=os.path.join(CLIENT_HOME, DETAILED_LOG_FILE)
DebugLogger.log=DebugLogger.DebugLogger(logfile).log DebugLogger.log=DebugLogger.DebugLogger(logfile).log
# Import Zope (or Main) # Import Zope (or Main)
exec "import "+MODULE in {} exec "import "+MODULE in {}
# Location of the ZServer log file. This file logs all ZServer activity. # Location of the ZServer log file. This file logs all ZServer activity.
# You may wish to create different logs for different servers. See # You may wish to create different logs for different servers. See
# medusa/logger.py for more information. # medusa/logger.py for more information.
if not os.path.isabs(LOG_FILE): if not os.path.isabs(LOG_FILE):
LOG_PATH=os.path.join(CLIENT_HOME, LOG_FILE) LOG_PATH=os.path.join(CLIENT_HOME, LOG_FILE)
else: else:
LOG_PATH=LOG_FILE LOG_PATH=LOG_FILE
# Location of the ZServer pid file. When ZServer starts up it will write # Location of the ZServer pid file. When ZServer starts up it will write
# its PID to this file. # its PID to this file.
PID_FILE=os.path.join(CLIENT_HOME, 'Z2.pid') PID_FILE=os.path.join(CLIENT_HOME, 'Z2.pid')
# import ZServer stuff # import ZServer stuff
# First, we need to increase the number of threads # First, we need to increase the number of threads
if MODULE=='Zope': if MODULE=='Zope':
from ZServer import setNumberOfThreads from ZServer import setNumberOfThreads
setNumberOfThreads(NUMBER_OF_THREADS) setNumberOfThreads(NUMBER_OF_THREADS)
from ZServer import resolver, logger, asyncore from ZServer import resolver, logger, asyncore
from ZServer import zhttp_server, zhttp_handler from ZServer import zhttp_server, zhttp_handler
from ZServer.WebDAVSrcHandler import WebDAVSrcHandler from ZServer.WebDAVSrcHandler import WebDAVSrcHandler
from ZServer import PCGIServer,FTPServer,FCGIServer from ZServer import PCGIServer,FTPServer,FCGIServer
from ZServer import secure_monitor_server from ZServer import secure_monitor_server
## ZServer startup ## ZServer startup
## ##
# Resolver and Logger, used by other servers # Resolver and Logger, used by other servers
if DNS_IP: if DNS_IP:
rs = resolver.caching_resolver(DNS_IP) rs = resolver.caching_resolver(DNS_IP)
else: else:
rs=None rs=None
if READ_ONLY: if READ_ONLY:
lg = logger.file_logger('-') # log to stdout lg = logger.file_logger('-') # log to stdout
elif os.environ.has_key('ZSYSLOG'): elif os.environ.has_key('ZSYSLOG'):
lg = logger.syslog_logger(os.environ['ZSYSLOG']) lg = logger.syslog_logger(os.environ['ZSYSLOG'])
elif os.environ.has_key('ZSYSLOG_SERVER'): elif os.environ.has_key('ZSYSLOG_SERVER'):
lg = logger.syslog_logger(string.split(os.environ['ZSYSLOG_SERVER'], ':')) lg = logger.syslog_logger(string.split(os.environ['ZSYSLOG_SERVER'], ':'))
else: else:
lg = logger.file_logger(LOG_PATH) lg = logger.file_logger(LOG_PATH)
# HTTP Server # HTTP Server
if HTTP_PORT: if HTTP_PORT:
if type(HTTP_PORT) is type(0): HTTP_PORT=((IP_ADDRESS, HTTP_PORT),) if type(HTTP_PORT) is type(0): HTTP_PORT=((IP_ADDRESS, HTTP_PORT),)
for address, port in HTTP_PORT: for address, port in HTTP_PORT:
hs = zhttp_server( hs = zhttp_server(
...@@ -633,9 +634,9 @@ if HTTP_PORT: ...@@ -633,9 +634,9 @@ if HTTP_PORT:
zh = zhttp_handler(MODULE, '', HTTP_ENV) zh = zhttp_handler(MODULE, '', HTTP_ENV)
hs.install_handler(zh) hs.install_handler(zh)
# WebDAV source Server (runs HTTP, but munges request to return # WebDAV source Server (runs HTTP, but munges request to return
# 'manage_FTPget'). # 'manage_FTPget').
if WEBDAV_SOURCE_PORT: if WEBDAV_SOURCE_PORT:
if type(WEBDAV_SOURCE_PORT) is type(0): if type(WEBDAV_SOURCE_PORT) is type(0):
WEBDAV_SOURCE_PORT=((IP_ADDRESS, WEBDAV_SOURCE_PORT),) WEBDAV_SOURCE_PORT=((IP_ADDRESS, WEBDAV_SOURCE_PORT),)
for address, port in WEBDAV_SOURCE_PORT: for address, port in WEBDAV_SOURCE_PORT:
...@@ -658,8 +659,8 @@ if WEBDAV_SOURCE_PORT: ...@@ -658,8 +659,8 @@ if WEBDAV_SOURCE_PORT:
zh = WebDAVSrcHandler(MODULE, '', HTTP_ENV) zh = WebDAVSrcHandler(MODULE, '', HTTP_ENV)
hs.install_handler(zh) hs.install_handler(zh)
# FTP Server # FTP Server
if FTP_PORT: if FTP_PORT:
if type(FTP_PORT) is type(0): FTP_PORT=((IP_ADDRESS, FTP_PORT),) if type(FTP_PORT) is type(0): FTP_PORT=((IP_ADDRESS, FTP_PORT),)
for address, port in FTP_PORT: for address, port in FTP_PORT:
FTPServer( FTPServer(
...@@ -669,8 +670,8 @@ if FTP_PORT: ...@@ -669,8 +670,8 @@ if FTP_PORT:
resolver=rs, resolver=rs,
logger_object=lg) logger_object=lg)
# PCGI Server # PCGI Server
if PCGI_FILE and not READ_ONLY: if PCGI_FILE and not READ_ONLY:
PCGI_FILE=os.path.join(here, PCGI_FILE) PCGI_FILE=os.path.join(here, PCGI_FILE)
if os.path.exists(PCGI_FILE): if os.path.exists(PCGI_FILE):
zpcgi = PCGIServer( zpcgi = PCGIServer(
...@@ -681,8 +682,8 @@ if PCGI_FILE and not READ_ONLY: ...@@ -681,8 +682,8 @@ if PCGI_FILE and not READ_ONLY:
logger_object=lg) logger_object=lg)
# FastCGI Server # FastCGI Server
if FCGI_PORT and not READ_ONLY: if FCGI_PORT and not READ_ONLY:
fcgiPort = None fcgiPort = None
fcgiPath = None fcgiPath = None
try: try:
...@@ -697,8 +698,8 @@ if FCGI_PORT and not READ_ONLY: ...@@ -697,8 +698,8 @@ if FCGI_PORT and not READ_ONLY:
logger_object=lg) logger_object=lg)
# Monitor Server # Monitor Server
if MONITOR_PORT: if MONITOR_PORT:
from AccessControl.User import emergency_user from AccessControl.User import emergency_user
if not hasattr(emergency_user, '__null_user__'): if not hasattr(emergency_user, '__null_user__'):
pw = emergency_user._getPassword() pw = emergency_user._getPassword()
...@@ -715,10 +716,10 @@ if MONITOR_PORT: ...@@ -715,10 +716,10 @@ if MONITOR_PORT:
hostname=address, hostname=address,
port=port) port=port)
# Try to set uid to "-u" -provided uid. # Try to set uid to "-u" -provided uid.
# Try to set gid to "-u" user's primary group. # Try to set gid to "-u" user's primary group.
# This will only work if this script is run by root. # This will only work if this script is run by root.
try: try:
import pwd import pwd
try: try:
try: UID = string.atoi(UID) try: UID = string.atoi(UID)
...@@ -743,13 +744,13 @@ try: ...@@ -743,13 +744,13 @@ try:
pass pass
except KeyError: except KeyError:
zLOG.LOG("z2", zLOG.ERROR, ("can't find UID %s" % UID)) zLOG.LOG("z2", zLOG.ERROR, ("can't find UID %s" % UID))
except: except:
pass pass
# if it hasn't failed at this point, create a .pid file. # if it hasn't failed at this point, create a .pid file.
if not READ_ONLY: if not READ_ONLY:
pf = open(PID_FILE, 'w') pf = open(PID_FILE, 'w')
pid=str(os.getpid()) pid=str(os.getpid())
try: pid=str(os.getppid())+' '+pid try: pid=str(os.getppid())+' '+pid
...@@ -757,6 +758,14 @@ if not READ_ONLY: ...@@ -757,6 +758,14 @@ if not READ_ONLY:
pf.write(pid) pf.write(pid)
pf.close() pf.close()
except:
# Log startup exception and tell zdaemon not to restart us.
try:
zLOG.LOG("z2", zLOG.PANIC, "Startup exception",
error=sys.exc_info())
except: pass
sys.exit(0)
# Start Medusa, Ye Hass! # Start Medusa, Ye Hass!
sys.ZServerExitCode=0 sys.ZServerExitCode=0
asyncore.loop() asyncore.loop()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment