PWS headless - misc. questions - OSProcess might help
David T. Lewis
lewis at mail.msen.com
Sun Aug 29 15:49:02 UTC 1999
On Wed, Aug 25, 1999 at 05:31:36PM -0700, Peter William Lount wrote:
> Is there a way to have Smalltalk level code read the virtual machine unix
> command line arguments... I'd like to have squeak read an optional argument
> for the port that it should serve pages on... This allows many copies of
> the same vm to be started simply via a single unix script...
The primitive to support SystemDictionary>>getSystemAttribute is only
partly implemented in the Unix sources (at least the version I have; maybe
it's been updated recently). The code is in sqXWindow.c if you want to
fix it up.
> I'd like to create a Apache Module if none exists, modsqueak, for Apache to
> talk with squeak vm processes via a tcp packet or shared memory. However,
> it would still require squeak to be able to respond instantly to a incoming
> packet without having to poll for the darn packet...
As long as you are running this on some flabor of Unix, you may want
to have a look at the OSProcess code which I posted on
http://minnow.cc.gatech.edu/squeak.708 a while back. Once you've filed
the changes in and built a new VM, you can do the following possibly
Get an array of all the command line arguments:
"OSProcess thisSqueakOSProcess arguments inspect"
Start a headless image for your PWS, cloned from a running image but
without a display (the original image keeps running also):
"UnixProcess forkHeadlessSqueakAndDoThenQuit: aBlockToStartUpThePWS"
I don't know how Apache modules work, but if you just need access to
stdin, stdout and stderr (like for a CGI script), then these are
"OSProcess thisSqueakOSProcess stdIn"
"OSProcess thisSqueakOSProcess stdOut"
"OSProcess thisSqueakOSProcess stdErr"
The standard input stream does blocking reads, which would be good for
a CGI script, since it does not leave Squeak in a polling loop while
waiting for input.
OSProcess works on the new 2.5 image (with the 2.4 code base for the VM).
If the VM code you are using is newer than mine (I think Ian has been
working on it since the 2.4 release), you may need to hack sqXWindow.c
a bit on your own, but it's pretty straightforward. This should run fine
on FreeBSD (I wrote in under Linux), but I'd appreciate if someone can
confirm that for me.
The code I posted on the swiki seems to evaporate from time to time. I
reloaded it this morning so you can grab it from the swiki, but just send
me email if you have trouble getting it.
Hope this helps.
More information about the Squeak-dev