Commit f6729664 authored by 's avatar

- added 'runzope' and 'zopectl' as entry points for instance scripts

- made instance scripts more suitable for egg based installs
parent 3dc88265
......@@ -38,7 +38,7 @@ How to build and install Zope from source code on Windows.
username/password for the admin user.
* We are now ready to start zope. Run:
% {zope_instance}\run_zope.bat.
% {zope_instance}\bin\runzope.bat
Zope should start with nice log messages being printed to
stdout. When Zope is ready, you should see:
> ------
......@@ -47,11 +47,12 @@ How to build and install Zope from source code on Windows.
Press Ctrl+C to stop this instance of the server.
* Optionally, install as a Windows service. Execute:
% python {zope_instance}\zope_service.py
% python {zope_instance}\bin\zopeservice.py
to see the valid options. You may want something like:
% python {zope_instance}\zope_service.py --startup=auto install
% python {zope_instance}\bin\zopeservice.py --startup=auto install
Once installed, it can be started any number of ways:
- python {zope_instance}\zope_service.py start
- % {zope_instance}\bin\zopectl.bat start
- % python {zope_instance}\bin\zopeservice.py start
- Control Panel
- net start service_short_name (eg, `net start Zope_-1227678699`)
- % net start service_short_name (eg, `net start Zope_-1227678699`)
......@@ -142,6 +142,8 @@ params = dict(name='Zope2',
'console_scripts' : [
'mkzeoinstance=Zope2.utilities.mkzeoinstance:main',
'mkzopeinstance=Zope2.utilities.mkzopeinstance:main',
'runzope=Zope2.Startup.run:run',
'zopectl=Zope2.Startup.zopectl:run',
'zpasswd=Zope2.utilities.zpasswd:main',
]
},
......
......@@ -41,15 +41,15 @@ def main():
usage(sys.stderr, msg)
sys.exit(2)
script = os.path.abspath(sys.argv[0])
script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
user = None
password = None
skeltarget = None
skelsrc = None
python = None
if check_buildout():
python = os.path.abspath('bin/zopepy')
if check_buildout(script_path):
python = os.path.join(script_path, 'zopepy')
for opt, arg in opts:
if opt in ("-d", "--dir"):
......@@ -127,6 +127,7 @@ def main():
"PYTHON":PYTHON,
"PYTHONW":PYTHONW,
"INSTANCE_HOME": instancehome,
"ZOPE_SCRIPTS": script_path,
"ZOPE2PATH": zope2path,
}
......@@ -186,24 +187,30 @@ def write_inituser(fn, user, password):
fp.close()
os.chmod(fn, 0644)
def check_buildout():
def check_buildout(script_path):
""" Are we running from within a buildout which supplies 'zopepy'?
"""
if os.path.exists('buildout.cfg'):
buildout_cfg = os.path.join(os.path.dirname(script_path), 'buildout.cfg')
if os.path.exists(buildout_cfg):
from ConfigParser import RawConfigParser
parser = RawConfigParser()
parser.read('buildout.cfg')
parser.read(buildout_cfg)
return 'zopepy' in parser.sections()
def get_zope2path(python):
""" Get Zope2 path from selected Python interpreter.
"""
p = os.popen('"%s" -c"import os, Zope2; '
'print os.path.realpath(os.path.dirname(Zope2.__file__))"' % python)
zope2file = ''
p = os.popen('"%s" -c"import Zope2; print Zope2.__file__"' % python)
try:
return p.readline()[:-1]
zope2file = p.readline()[:-1]
finally:
p.close()
if not zope2file:
# fall back to current Python interpreter
import Zope2
zope2file = Zope2.__file__
return os.path.abspath(os.path.dirname(os.path.dirname(zope2file)))
if __name__ == "__main__":
main()
@set PYTHON=<<PYTHON>>
@set INSTANCE_HOME=<<INSTANCE_HOME>>
@set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf
@set ZOPE_RUN=<<ZOPE2PATH>>\Startup\run.py
"%PYTHON%" "%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
@set ZOPE_RUN=<<ZOPE_SCRIPTS>>\runzope
"%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
#! /bin/sh
PYTHON="<<PYTHON>>"
INSTANCE_HOME="<<INSTANCE_HOME>>"
CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf"
ZOPE_RUN="<<ZOPE_SCRIPTS>>/runzope"
export INSTANCE_HOME
ZOPE_RUN="<<ZOPE2PATH>>/Startup/run.py"
exec "$PYTHON" "$ZOPE_RUN" -C "$CONFIG_FILE" "$@"
exec "$ZOPE_RUN" -C "$CONFIG_FILE" "$@"
@set PYTHON=<<PYTHON>>
@set INSTANCE_HOME=<<INSTANCE_HOME>>
@set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf
@set ZDCTL=<<ZOPE2PATH>>\Startup\zopectl.py
"%PYTHON%" "%ZDCTL%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
@set ZDCTL=<<ZOPE_SCRIPTS>>\zopectl
"%ZDCTL%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
......@@ -3,9 +3,8 @@
PYTHON="<<PYTHON>>"
INSTANCE_HOME="<<INSTANCE_HOME>>"
CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf"
ZDCTL="<<ZOPE_SCRIPTS>>/zopectl"
export INSTANCE_HOME
export PYTHON
ZDCTL="<<ZOPE2PATH>>/Startup/zopectl.py"
exec "$PYTHON" "$ZDCTL" -C "$CONFIG_FILE" "$@"
exec "$ZDCTL" -C "$CONFIG_FILE" "$@"
......@@ -81,15 +81,19 @@ Usage:
import sys, os
# these are replacements from mkzopeinstance
PYTHON = r'<<PYTHON>>'
INSTANCE_HOME = r'<<INSTANCE_HOME>>'
ZOPE_SCRIPTS = r'<<ZOPE_SCRIPTS>>'
ZOPE2PATH = r'<<ZOPE2PATH>>'
ZOPE_RUN = r'<<ZOPE2PATH>>\Startup\run.py'
CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZOPE_HOME
ZOPE_RUN = os.path.join(ZOPE_SCRIPTS, 'runzope')
CONFIG_FILE = os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
PYTHONSERVICE_EXE = os.path.join(ZOPE_SCRIPTS, 'PythonService.exe')
os.environ["INSTANCE_HOME"] = INSTANCE_HOME
# XXX: we need to find nt_svcutils.service
sys.path[0:0] = [ZOPE2PATH]
from nt_svcutils.service import Service
servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower()))
......@@ -105,8 +109,8 @@ class InstanceService(Service):
if os.path.isfile(PYTHONSERVICE_EXE):
_exe_name_ = PYTHONSERVICE_EXE
process_runner = PYTHON
process_args = '"%s" -C "%s"' % (ZOPE_RUN, CONFIG_FILE)
process_runner = ZOPE_RUN
process_args = '-C "%s"' % CONFIG_FILE
if __name__ == '__main__':
import win32serviceutil
......
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