[GOODIE] Headless Squeak for OS X (Re: Mac VM 3.2.X)

Marcel Weiher marcel at metaobject.com
Sun Apr 7 08:09:44 UTC 2002


On Sunday, April 7, 2002, at 06:45  Uhr, Brian T. Rice wrote:

>> 3) headless squeak
>>
>> There seem that the Mac VM has no headless mode. This could be usefull 
>> for
>> Squeak server applications like Swiki or Seaside. If we have this 
>> possibility,
>> we could start Squeak with a script in /library/StartupItems.
>>
>> How many of you are interested in these changes ?
>
> I'd be really interested in this, especially for working towards the 
> Modular Squeak Image upgrading in 3.3: then I could run squeak as a 
> good old BSD network daemon under OS X. :)

Well, I've always said how trivial this is with the architecture of the 
CocoaSqueak VM, and today I guess I'm going to put my money where my 
mouth is:

All you have to do is create a new "Foundation Tool" project, add the 
Squeak.framework to its frameworks and adjust main to load + run a 
Squeak image.  I just did it, elapsed time exactly 10 minutes (much of 
that rummaging around in the image for the code to make the image start 
up Seaside automatically when starting up).  This is code:


------------- snip --------------
#import <Foundation/Foundation.h>
#import <Squeak/SqueakInterpreter.h>

int main (int argc, const char * argv[]) {
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     id imageName=[NSString stringWithCString:argv[1]];
     id interpreter =[SqueakInterpreter interpreter];

     [interpreter readImageFile:imageName withHeapSize:64 * 1024 * 1024];
     [interpreter setStackCacheEntries:64];
     [interpreter setContextCacheEntries:64];
     [interpreter startInterpreter];

     [pool release];
     return 0;
}
----------- snip --------------


and this is the complete project.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: squeakserver.tgz
Type: application/x-gzip
Size: 1825 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20020407/f0b22d5e/squeakserver.bin
-------------- next part --------------


Enhancements / generality left as an exercise to the reader.  A tool 
like this can't use the bundle features, because there is no bundle, but 
it is probably possible to build a bundled headless application as well.

Marcel

--
Marcel Weiher				Metaobject Software Technologies
marcel at metaobject.com		www.metaobject.com
Metaprogramming for the Graphic Arts.   HOM, IDEAs, MetaAd etc.


More information about the Squeak-dev mailing list