Commit 918a2843 authored by 's avatar

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

- made instance scripts more suitable for egg based installs
parent 89159bcf
...@@ -15,9 +15,14 @@ Features Added ...@@ -15,9 +15,14 @@ Features Added
- zope.testing = 3.7.7 - zope.testing = 3.7.7
- scripts: Added 'runzope' and 'zopectl' as entry points for instance scripts.
Bugs Fixed Bugs Fixed
++++++++++ ++++++++++
- mkzopeinstance: Made instance scripts more suitable for egg based installs.
If you are using a customized skel, it has to be updated.
- Five: Fixed the permissions creation feature added in Zope 2.12.0a2. - Five: Fixed the permissions creation feature added in Zope 2.12.0a2.
- LP #399633: fixed interpreter paths - LP #399633: fixed interpreter paths
......
...@@ -38,7 +38,7 @@ How to build and install Zope from source code on Windows. ...@@ -38,7 +38,7 @@ How to build and install Zope from source code on Windows.
username/password for the admin user. username/password for the admin user.
* We are now ready to start zope. Run: * 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 Zope should start with nice log messages being printed to
stdout. When Zope is ready, you should see: stdout. When Zope is ready, you should see:
> ------ > ------
...@@ -47,11 +47,12 @@ How to build and install Zope from source code on Windows. ...@@ -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. Press Ctrl+C to stop this instance of the server.
* Optionally, install as a Windows service. Execute: * 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: 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: 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 - Control Panel
- net start service_short_name (eg, `net start Zope_-1227678699`) - % net start service_short_name (eg, `net start Zope_-1227678699`)
...@@ -143,6 +143,8 @@ params = dict(name='Zope2', ...@@ -143,6 +143,8 @@ params = dict(name='Zope2',
'console_scripts' : [ 'console_scripts' : [
'mkzeoinstance=Zope2.utilities.mkzeoinstance:main', 'mkzeoinstance=Zope2.utilities.mkzeoinstance:main',
'mkzopeinstance=Zope2.utilities.mkzopeinstance:main', 'mkzopeinstance=Zope2.utilities.mkzopeinstance:main',
'runzope=Zope2.Startup.run:run',
'zopectl=Zope2.Startup.zopectl:run',
'zpasswd=Zope2.utilities.zpasswd:main', 'zpasswd=Zope2.utilities.zpasswd:main',
] ]
}, },
......
...@@ -41,15 +41,15 @@ def main(): ...@@ -41,15 +41,15 @@ def main():
usage(sys.stderr, msg) usage(sys.stderr, msg)
sys.exit(2) sys.exit(2)
script = os.path.abspath(sys.argv[0]) script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
user = None user = None
password = None password = None
skeltarget = None skeltarget = None
skelsrc = None skelsrc = None
python = None python = None
if check_buildout(): if check_buildout(script_path):
python = os.path.abspath('bin/zopepy') python = os.path.join(script_path, 'zopepy')
for opt, arg in opts: for opt, arg in opts:
if opt in ("-d", "--dir"): if opt in ("-d", "--dir"):
...@@ -127,6 +127,7 @@ def main(): ...@@ -127,6 +127,7 @@ def main():
"PYTHON":PYTHON, "PYTHON":PYTHON,
"PYTHONW":PYTHONW, "PYTHONW":PYTHONW,
"INSTANCE_HOME": instancehome, "INSTANCE_HOME": instancehome,
"ZOPE_SCRIPTS": script_path,
"ZOPE2PATH": zope2path, "ZOPE2PATH": zope2path,
} }
...@@ -186,24 +187,30 @@ def write_inituser(fn, user, password): ...@@ -186,24 +187,30 @@ def write_inituser(fn, user, password):
fp.close() fp.close()
os.chmod(fn, 0644) os.chmod(fn, 0644)
def check_buildout(): def check_buildout(script_path):
""" Are we running from within a buildout which supplies 'zopepy'? """ 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 from ConfigParser import RawConfigParser
parser = RawConfigParser() parser = RawConfigParser()
parser.read('buildout.cfg') parser.read(buildout_cfg)
return 'zopepy' in parser.sections() return 'zopepy' in parser.sections()
def get_zope2path(python): def get_zope2path(python):
""" Get Zope2 path from selected Python interpreter. """ Get Zope2 path from selected Python interpreter.
""" """
p = os.popen('"%s" -c"import os, Zope2; ' zope2file = ''
'print os.path.realpath(os.path.dirname(Zope2.__file__))"' % python) p = os.popen('"%s" -c"import Zope2; print Zope2.__file__"' % python)
try: try:
return p.readline()[:-1] zope2file = p.readline()[:-1]
finally: finally:
p.close() 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__": if __name__ == "__main__":
main() main()
@set PYTHON=<<PYTHON>>
@set INSTANCE_HOME=<<INSTANCE_HOME>> @set INSTANCE_HOME=<<INSTANCE_HOME>>
@set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf @set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf
@set ZOPE_RUN=<<ZOPE2PATH>>\Startup\run.py @set ZOPE_RUN=<<ZOPE_SCRIPTS>>\runzope
"%PYTHON%" "%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
"%ZOPE_RUN%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
#! /bin/sh #! /bin/sh
PYTHON="<<PYTHON>>"
INSTANCE_HOME="<<INSTANCE_HOME>>" INSTANCE_HOME="<<INSTANCE_HOME>>"
CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf" CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf"
ZOPE_RUN="<<ZOPE_SCRIPTS>>/runzope"
export INSTANCE_HOME export INSTANCE_HOME
ZOPE_RUN="<<ZOPE2PATH>>/Startup/run.py" exec "$ZOPE_RUN" -C "$CONFIG_FILE" "$@"
exec "$PYTHON" "$ZOPE_RUN" -C "$CONFIG_FILE" "$@"
@set PYTHON=<<PYTHON>> @set PYTHON=<<PYTHON>>
@set INSTANCE_HOME=<<INSTANCE_HOME>> @set INSTANCE_HOME=<<INSTANCE_HOME>>
@set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf @set CONFIG_FILE=%INSTANCE_HOME%\etc\zope.conf
@set ZDCTL=<<ZOPE2PATH>>\Startup\zopectl.py @set ZDCTL=<<ZOPE_SCRIPTS>>\zopectl
"%PYTHON%" "%ZDCTL%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
"%ZDCTL%" -C "%CONFIG_FILE%" %1 %2 %3 %4 %5 %6 %7
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
PYTHON="<<PYTHON>>" PYTHON="<<PYTHON>>"
INSTANCE_HOME="<<INSTANCE_HOME>>" INSTANCE_HOME="<<INSTANCE_HOME>>"
CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf" CONFIG_FILE="<<INSTANCE_HOME>>/etc/zope.conf"
ZDCTL="<<ZOPE_SCRIPTS>>/zopectl"
export INSTANCE_HOME export INSTANCE_HOME
export PYTHON export PYTHON
ZDCTL="<<ZOPE2PATH>>/Startup/zopectl.py" exec "$ZDCTL" -C "$CONFIG_FILE" "$@"
exec "$PYTHON" "$ZDCTL" -C "$CONFIG_FILE" "$@"
...@@ -81,15 +81,19 @@ Usage: ...@@ -81,15 +81,19 @@ Usage:
import sys, os import sys, os
# these are replacements from mkzopeinstance # these are replacements from mkzopeinstance
PYTHON = r'<<PYTHON>>'
INSTANCE_HOME = r'<<INSTANCE_HOME>>' INSTANCE_HOME = r'<<INSTANCE_HOME>>'
ZOPE_SCRIPTS = r'<<ZOPE_SCRIPTS>>'
ZOPE2PATH = r'<<ZOPE2PATH>>'
ZOPE_RUN = r'<<ZOPE2PATH>>\Startup\run.py' ZOPE_RUN = os.path.join(ZOPE_SCRIPTS, 'runzope')
CONFIG_FILE= os.path.join(INSTANCE_HOME, 'etc', 'zope.conf') CONFIG_FILE = os.path.join(INSTANCE_HOME, 'etc', 'zope.conf')
PYTHONSERVICE_EXE=r'%s\bin\PythonService.exe' % ZOPE_HOME PYTHONSERVICE_EXE = os.path.join(ZOPE_SCRIPTS, 'PythonService.exe')
os.environ["INSTANCE_HOME"] = INSTANCE_HOME 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 from nt_svcutils.service import Service
servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower())) servicename = 'Zope_%s' % str(hash(INSTANCE_HOME.lower()))
...@@ -105,8 +109,8 @@ class InstanceService(Service): ...@@ -105,8 +109,8 @@ class InstanceService(Service):
if os.path.isfile(PYTHONSERVICE_EXE): if os.path.isfile(PYTHONSERVICE_EXE):
_exe_name_ = PYTHONSERVICE_EXE _exe_name_ = PYTHONSERVICE_EXE
process_runner = PYTHON process_runner = ZOPE_RUN
process_args = '"%s" -C "%s"' % (ZOPE_RUN, CONFIG_FILE) process_args = '-C "%s"' % CONFIG_FILE
if __name__ == '__main__': if __name__ == '__main__':
import win32serviceutil 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