Commit fd335bd0 authored by Sidnei da Silva's avatar Sidnei da Silva

Major service enhancements. Service cleanly shuts down child, and if child

fails the tail of the process output (which generally contains a traceback)
is
written to the event log.

Minor tweaks to the Windows build 'clean' process and documentation tweaks.

Don't kill the service if we can't write to the event log
parent baff3bac
......@@ -3,6 +3,9 @@ Building and installing Zope from source
Welcome to Zope! This document describes building and installing
Zope on UNIX and Linux.
See WINDOWS.txt for information about Windows. See the PLATFORMS
directory for notes about various other platforms.
System requirements when building from source
......
How to build and install Zope from source code on Windows.
----------------------------------------------------------
These instructions appear to work for 2.7 and the trunk:
* Ensure you have the correct MSVC version installed for the
version of Python you will be using.
* Install (or build from sources) Python
http://www.python.org
* Install (or build from sources) the Python for Windows extensions
http://sourceforge.net/projects/pywin32/
* Unpack the Zope source distribution or pull from CVS. Change
to that directory.
* Execute:
% python.exe inst\configure.py
It should say something like:
>
> - Zope top-level binary directory will be c:\Zope-2.7.
> - Makefile written.
>
> Next, run the Visual C++ batch file "VCVARS32.bat" and then "nmake".
(run 'configure.py --help' to see how to change things)
* 'makefile' will have ben created. As instructed, execute 'nmake'.
If the build succeeds, the last message printed should be:
> Zope built. Next, do 'nmake install'.
* As instructed, execute 'nmake install'. A few warnings will be generated,
but they can be ignored. The last message in the build process should be:
> Zope binaries installed successfully.
* If you are running from CVS, the build may fail:
See http://collector.zope.org/Zope/1530
> running install_data
> error: can't copy 'version.txt': no matching files
> NMAKE : fatal error U1077: '"e:\src\python-2.3-cvs\pcbuild\python.exe"' : return code '0x1'
> Stop.
If you see this error, edit setup.py and comment the line referencing
'version.txt'
* Zope itself has now been installed. We need to create an instance. Run:
% python.exe {install_path}\bin\mkzopeinstance.py
We will be prompted, via the console, for the instance directory and
username/password for the admin user.
* We are now ready to start zope. Run:
% {zope_instance}\run_zope.bat.
Zope should start with nice log messages being printed to
stdout. When Zope is ready, you should see:
> ------
> 2004-10-13T12:27:58 INFO(0) Zope Ready to handle requests
Press Ctrl+C to stop this instance of the server.
* Optionally, install as a Windows service. Execute:
% python {zope_instance}\zope_service.py
to see the valid options. You may want something like:
% python {zope_instance}\zope_service.py --startup=auto install
Once installed, it can be started any number of ways:
- python {zope_instance}\zope_service.py start
- Control Panel
- net start service_short_name (eg, "net start Zope_-1227678699"
......@@ -31,14 +31,14 @@ CD=cd
XCOPY=xcopy /i /s /e /y
COPY=copy
.PHONY: clean install build unbuild
.PHONY: default
default: build
# default: The default step (invoked when make is called without a target)
@ echo.
@ echo Zope built. Next, do 'nmake install'.
@ echo
@ echo.
.PHONY: clean install build unbuild
.PHONY: default
# build: Do whatever 'setup.py build' implies
build:
......@@ -47,7 +47,7 @@ build:
# unbuild: Remove the build directory (undo the make build step)
unbuild:
$(RMRF) $(BUILD_BASE)
-$(RMRF) $(BUILD_BASE)
# install: Install a software home.
install: build
......@@ -62,7 +62,7 @@ install: build
# the source directory for good measure.
clean: unbuild
$(CD) "$(BASE_DIR)
$(RM) /s *.pyc *.pyo *.dll *.o *.obj *.pyd
-$(RM) /s *.pyc *.pyo *.dll *.o *.obj *.pyd
......@@ -23,7 +23,7 @@ QUIET=0
if sys.platform == 'win32':
PREFIX = 'c:\\Zope-' + versions.ZOPE_MAJOR_VERSION
IN_MAKEFILE = 'Makefile.win.in'
MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake build"'
MAKE_COMMAND='the Visual C++ batch file "VCVARS32.bat" and then "nmake"'
else:
PREFIX = '/opt/Zope-' + versions.ZOPE_MAJOR_VERSION
IN_MAKEFILE = 'Makefile.in'
......
This diff is collapsed.
......@@ -4,5 +4,5 @@
@set SOFTWARE_HOME=<<SOFTWARE_HOME>>
@set CONFIG_FILE=<<INSTANCE_HOME>>\etc\zope.conf
@set PYTHONPATH=%SOFTWARE_HOME%
@set ZOPE_RUN=%SOFTWARE_HOME%\Zope\Startup\run.py
@set ZOPE_RUN=%SOFTWARE_HOME%\Zope2\Startup\run.py
"%PYTHON%" "%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
......@@ -38,8 +38,9 @@ Usage:
install : Installs the service
update : Updates the service, use this when you change
the service class implementation
update : Updates the service. Use this if you change any
configuration settings and need the service to be
re-registered.
remove : Removes the service
......@@ -53,13 +54,9 @@ Usage:
debug : Runs the service in debug mode
You can view the usage options by running ntservice.py without any
You can view the usage options by running this module without any
arguments.
Note: you may have to register the Python service program first,
win32\PythonService.exe /register
Starting Zope
Start Zope by clicking the 'start' button in the services control
......@@ -74,40 +71,61 @@ Usage:
Event logging
Zope events are logged to the NT application event log. Use the
event viewer to keep track of Zope events.
Service related events (such as startup, shutdown, or errors executing
the Zope process) are logged to the NT application event log. Use the
event viewer to see these events.
Note: to successfully run this script, the Zope software home needs to be on
the PYTHONPATH.
"""
Zope Events are still written to the Zope event logs.
import os.path
from os.path import dirname as dn
import sys
"""
import sys, os
# these are replacements from mkzopeinstance
PYTHONW = r'<<PYTHONW>>'
PYTHON = r'<<PYTHON>>'
SOFTWARE_HOME=r'<<SOFTWARE_HOME>>'
INSTANCE_HOME = r'<<INSTANCE_HOME>>'
ZOPE_HOME = r'<<ZOPE_HOME>>'
ZOPE_RUN = r'%s\Zope\Startup\run.py' % SOFTWARE_HOME
ZOPE_RUN = r'%s\Zope2\Startup\run.py' % SOFTWARE_HOME
CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZOPE_HOME
sys.path.insert(0, SOFTWARE_HOME)
sys.path.insert(1, os.path.join(SOFTWARE_HOME, 'third_party', 'docutils'))
sys.path.insert(2, os.path.join(SOFTWARE_HOME, 'third_party', 'docutils', 'extras'))
# Setup the environment, so sub-processes see these variables
for check_dir in (os.path.join(SOFTWARE_HOME, 'third_party', 'docutils', 'extras'),
os.path.join(SOFTWARE_HOME, 'third_party', 'docutils'),
SOFTWARE_HOME,
):
parts = os.environ.get("PYTHONPATH", "").split(os.pathsep)
if check_dir not in parts:
parts = filter(None, [check_dir] + parts)
os.environ["PYTHONPATH"] = os.pathsep.join(parts)
os.environ["INSTANCE_HOME"] = INSTANCE_HOME
# Ensure SOFTWARE_HOME is on our current sys.path so we can import the
# nt_svcutils package. Note we don't need the docutils dirs in sys.path, as
# only Zope itself (our child process) uses it, and that happens via
# PYTHONPATH
if SOFTWARE_HOME not in sys.path:
sys.path.insert(0, SOFTWARE_HOME)
from nt_svcutils.service import Service
servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower()))
class InstanceService(Service):
start_cmd = '"%s" "%s" -C "%s"' % (PYTHONW, ZOPE_RUN, CONFIG_FILE)
_svc_name_ = servicename
_svc_display_name_ = 'Zope instance at %s' % INSTANCE_HOME
_exe_name_ = PYTHONSERVICE_EXE
# _svc_description_ can also be set (but what to say isn't clear!)
# If the exe we expect is not there, let the service framework search
# for it. This will be true for people running from source builds and
# relying on pre-installed pythonservice.exe.
# Note this is only used at install time, not runtime.
if os.path.isfile(PYTHONSERVICE_EXE):
_exe_name_ = PYTHONSERVICE_EXE
process_runner = PYTHON
process_args = '"%s" -C "%s"' % (ZOPE_RUN, CONFIG_FILE)
if __name__ == '__main__':
import win32serviceutil
......
......@@ -93,9 +93,11 @@ def main():
user, password = get_inituser()
# we need to distinguish between python.exe and pythonw.exe under
# Windows in order to make Zope run using python.exe when run in a
# console window and pythonw.exe when run as a service, so we do a bit
# of sniffing here.
# Windows. Zope is always run using 'python.exe' (even for services),
# however, it may be installed via pythonw.exe (as a sub-process of an
# installer). Thus, sys.executable may not be the executable we use.
# We still provide both PYTHON and PYTHONW, but PYTHONW should never
# need be used.
psplit = os.path.split(sys.executable)
exedir = os.path.join(*psplit[:-1])
pythonexe = os.path.join(exedir, 'python.exe')
......
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