Re: [Webware-devel] Improvement of launch scripts

2005-09-10 Thread Jason Hildebrand
Hi Christoph,

Both of your suggestions sound good to me.

peace,
Jason

On Fri, 2005-09-09 at 12:24 +0200, Christoph Zwerschke wrote:
> Problem 1:
> The AppServer and AppServer.bat shell skripts do not work if they are
> not started from their containing directories. Particularly, I cannot
> used "startproc" to start the AppServer script.

> Suggestion for improvement:

> Add this to AppServer:
> cd $(dirname $0)

> Add this to AppServer.bat:
> if exist $~dpn0 cd /d %~dp0

> (I have added the "if" because ~dp0 probably only exists on NT/2K/XP,
> not 95/98/ME.)

> Problem 2:
> The AppServer will not start any more if you move a directory that has
> been created with MakeAppWorkDir. This is due to the fact that the work
> dir is hard-coded in the Launch.py and NTService.py files that are
> created by MakeAppWorkDir.

> Suggestion for improvement:
> Instead of setting appWorkPath = '...' in Launch.py and NTService,
> use something like
> appWorkPath = os.path.dirname(os.path.join(os.getcwd(), sys.argv[0]))
> It is done that way in the version of Launch.py that exists in the
> WebKit directory, but not in the version that is created by MakeAppWorkDir.

> If you think these suggestions make sense, I would like to make the
> appropriate changes in the trunk.


> ---
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> ___
> Webware-devel mailing list
> Webware-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/webware-devel
--
Jason D. Hildebrand
T: 204 775 1212
E: [EMAIL PROTECTED]



---
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel


Re: [Webware-devel] Improvement of launch scripts

2005-09-14 Thread Seth Remington
On Fri, 2005-09-09 at 12:24 +0200, Christoph Zwerschke wrote:
> Problem 1:
> The AppServer and AppServer.bat shell skripts do not work if they are 
> not started from their containing directories. Particularly, I cannot 
> used "startproc" to start the AppServer script.
> 
> Suggestion for improvement:
> 
> Add this to AppServer:
> cd $(dirname $0)
> 
> Add this to AppServer.bat:
> if exist $~dpn0 cd /d %~dp0
> 
> (I have added the "if" because ~dp0 probably only exists on NT/2K/XP, 
> not 95/98/ME.)
> 
> Problem 2:
> The AppServer will not start any more if you move a directory that has 
> been created with MakeAppWorkDir. This is due to the fact that the work 
> dir is hard-coded in the Launch.py and NTService.py files that are 
> created by MakeAppWorkDir.
> 
> Suggestion for improvement:
> Instead of setting appWorkPath = '...' in Launch.py and NTService,
> use something like
> appWorkPath = os.path.dirname(os.path.join(os.getcwd(), sys.argv[0]))
> It is done that way in the version of Launch.py that exists in the 
> WebKit directory, but not in the version that is created by MakeAppWorkDir.
> 
> If you think these suggestions make sense, I would like to make the 
> appropriate changes in the trunk.
> 

I think both of these suggestions would be good improvements. The only
input I would have would be to also handle the -l or --library option
that adds a lib/ directory to the Python path...

sys.path.append(os.path.join(appWorkPath, 'lib'))

-Seth

-- 
Seth Remington
SaberLogic, LLC
661-B Weber Drive
Wadsworth, Ohio 44281
Phone: (330)335-6442
Fax: (330)336-8559



---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel


Re: [Webware-devel] Improvement of launch scripts

2005-09-14 Thread Christoph Zwerschke

I think both of these suggestions would be good improvements. The only
input I would have would be to also handle the -l or --library option
that adds a lib/ directory to the Python path...

sys.path.append(os.path.join(appWorkPath, 'lib'))


That makes sense, I will take heed of that: The lib directories that 
have been defined when running MakeAppWorkDir option will be interpreted 
as relative to the WorkDir unless they were defined with absolute path.


-- Christoph


---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel


Re: [Webware-devel] Improvement of launch scripts

2005-09-14 Thread Ian Bicking
On the general subject of a launch script, I've attached a Launch.py 
replacement that I've been using.  I'm not using it much anymore, since 
I'm not using Webware (at least this version of Webware), but it's 
worked okay in the past (maybe the attempt to kill existing app servers 
is too aggressive, though).  I don't have time to integrate it, but here 
it is for someone who is interested...


--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org
#!/usr/local/bin/python2.2

import os, sys, signal

webwarePath = '/usr/local/share/webware'
appWorkPath = '%%APP_WORK_DIR%%'
sys.path.extend([%%APP_PYTHON_PATH%%])

def main(args):
global webwarePath, appWorkPath
logFile = uid = gid = pidFile = None
newArgs = []
# @@: This really should be using getopt or something
for arg in args:
if arg.startswith('--webware-path='):
webwarePath = arg[15:]
elif arg.startswith('--working-path='):
appWorkPath = arg[15:]
elif arg.startswith('--log-file='):
logFile = arg[len('--log-file='):]
elif arg.startswith('--user='):
uid = arg[len('--user='):]
elif arg.startswith('--group='):
gid = arg[len('--group='):]
elif arg.startswith('--pid-file='):
pidFile = arg[len('--pid-file='):]
else:
newArgs.append(arg)
if uid:
try:
uid = int(uid)
except ValueError:
import pwd
try:
entry = pwd.getpwnam(uid)
except KeyError:
raise KeyError, "Bad username: %r; no such user 
exists" % uid
if not gid:
gid = entry[3]
uid = entry[2]
if gid:
try:
gid = int(gid)
except ValueError:
import grp
try:
entry = grp.getgrnam(gid)
except KeyError:
raise KeyError, "Bad group: %r; no such group 
exists" % gid
gid = entry[2]

if pidFile:
if os.path.exists(pidFile):
f = open(pidFile)
pid = int(f.read())
f.close()
print 'PID file (%s) contains PID %s; killing...' % 
(pidFile, pid),
try:
os.kill(pid, signal.SIGKILL)
except OSError, e:
if e.errno == 3: # No such process
print 'PID file was stale, continuing 
with startup.'
else:
raise
else:
print 'Signal sent, waiting for exit...',
try:
os.waitpid(pid, 0)
except OSError, e:
if e.errno == 10: # No such process
pass
else:
raise
print 'done.'
f = open(pidFile, 'w')
f.write(str(os.getpid()))
f.close()
if gid:
os.setgid(gid)
if uid:
os.setuid(uid)
#print 'Setting uid: %s; gid: %s' % (uid, gid)
if logFile:
f = open(logFile, 'a', 1) # 1==line buffered
sys.stdout = sys.stderr = f
pass
args = newArgs
# ensure Webware is on sys.path
sys.path.insert(0, webwarePath)

# import the master launcher
import WebKit.Launch

if len(args) < 2:
WebKit.Launch.usage()

# Go!
WebKit.Launch.launchWebKit(args[1], appWorkPath, args[2:])


if __name__=='__main__':
main(sys.argv)
#!/usr/local/bin/bash
#
# Startup script for WebKit on UNIX systems.
#
# See Webware/WebKit/Docs/InstallGuide.html for instructions.

# chkconfig: 2345 75 25
# description: WebKit is a Python application server, part of Webware.


# Configuration section

WEBKIT_DIR=%%APP_WORK_DIR%%
PID_FILE=/var/run/%%APP_NAME%%/%%APP_NAME%%.pid
LOG=/var/log/%%APP_NAME%%/%%APP_NAME%%.log
PYTHONPATH=
WEBWARE_USER=%%APP_USER%%

# end configuration section


# Source function library.
# Use the funtions provided by Red Hat or use our own
if [ -f /etc/rc.d/init.d/functions ]
then
. /etc/rc.d/init.d/functions
else

Re: [Webware-devel] Improvement of launch scripts

2005-09-14 Thread Christoph Zwerschke

Ian Bicking wrote:

> On the general subject of a launch script, I've attached a Launch.py 
replacement that I've been using.


Thanks. I will try to integrate this and the other changes until next week.

-- Chris


---
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel