Headless on Mac OS X

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Headless on Mac OS X

Aaron Rosenzweig-2
Hello All,

Does anyone run Pier headless on Mac OS X? I saw the nice tutorial here:

http://www.piercms.com/doc/deploy

But it only deals with starting up the VM and not how to close it  
gracefully when the entire server reboots.

I'm thinking of something along the lines of using "systemstarter" in  
Tiger or "launchctl" in Leopard. These both automatically issue a  
"start" and "stop" script. For example:

sudo systemstarter start "WebObjects Services"

or

sudo launchctl start com.apple.webobjects.wotaskd

Thanks,
-- Aaron
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

Mariano Martinez Peck


On Fri, Jul 31, 2009 at 12:17 AM, Aaron Rosenzweig <[hidden email]> wrote:
Hello All,

Does anyone run Pier headless on Mac OS X? I saw the nice tutorial here:

http://www.piercms.com/doc/deploy

But it only deals with starting up the VM and not how to close it gracefully when the entire server reboots.

I'm thinking of something along the lines of using "systemstarter" in Tiger or "launchctl" in Leopard. These both automatically issue a "start" and "stop" script. For example:

sudo systemstarter start "WebObjects Services"

or

sudo launchctl start com.apple.webobjects.wotaskd

I am sorry I don't know how Mac works, but I can tell you what I do in Linux (with other's help in a seaside thread)

startMyApp.sh:



#!/bin/sh
#settings
NOHUP="/usr/bin/nohup"
VM="/home/mariano/squeak/expury/build/squeak"
# Para produccion, como no van a estar las X, tengo que poner el -vm-display-null
VM_PARAMS="-mmap 200m -vm-sound-null"
IMAGE="destinoMochila.image"
#start the vm
$NOHUP "$VM" $VM_PARAMS "$IMAGE" &
# store in a file the PID of squeakVM
echo $! > evince.pid


stopMyApp.sh:

#!/bin/bash
PID=`cat evince.pid`
kill -15 $PID || exit 0
sleep 2
kill -2 $PID || exit 0
sleep 2
kill -1 $PID || exit 0
sleep 2
kill -9 $PID || exit 0

This has three nice things:

1) Doesn't do a kill -9 first but it tries to kill the process with better signals

2) I store the pid in a file so that then I know which process to kill

3) I use nohup so that I can start the process and then close the terminal (suppose you are trough ssh).

I hope this helps,

Mariano

 

Thanks,
-- Aaron
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

johnmci
In reply to this post by Aaron Rosenzweig-2
If you are using the macintosh carbon version of the VM, you can set LSBackgroundOnly=YES and then starting the VM will make it run headless as a background process.  Also see -headless as a cmd option

On Thu, Jul 30, 2009 at 8:17 PM, Aaron Rosenzweig <[hidden email]> wrote:
Hello All,

Does anyone run Pier headless on Mac OS X? I saw the nice tutorial here:

http://www.piercms.com/doc/deploy

But it only deals with starting up the VM and not how to close it gracefully when the entire server reboots.

I'm thinking of something along the lines of using "systemstarter" in Tiger or "launchctl" in Leopard. These both automatically issue a "start" and "stop" script. For example:

sudo systemstarter start "WebObjects Services"

or

sudo launchctl start com.apple.webobjects.wotaskd

Thanks,
-- Aaron
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki



--
===========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================



_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

Randal L. Schwartz
In reply to this post by Aaron Rosenzweig-2
>>>>> "Aaron" == Aaron Rosenzweig <[hidden email]> writes:

Aaron> I'm thinking of something along the lines of using "systemstarter" in
Aaron> Tiger or "launchctl" in Leopard. These both automatically issue a
Aaron> "start" and "stop" script.

I've had pretty good success building custom things with Lingon, which
is a nice GUI to the rather awkward launchctl.  I think there's a version
by the same folks for systemstarter.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

Aaron Rosenzweig-2
I'd like to thank Mariano, John, and Randal for giving me pointers,

Please someone correct me if I am wrong but I believe it is  
*impossible* to run Squeak headless in a nice manner on Mac OS X with  
the ready made VMs that are available for download.

LSBackgroundOnly - setting this property to "true" in the plist file  
seems to have no effect.

Using "-headless" from the command line and specifying the path to  
the smalltalk image works like a charm but *only* from a terminal  
window... which is pretty useless... Because if I'm doing it there I  
might was well double click the .app bundle and have all the bells  
and whistles in a GUI environment.

The idea is to use launchctl to control the startup and shutdown of  
the daemon Squeak process without a user even having to login. When I  
try to launch it this way (as the "appserver" user) I get this error  
in the unix system console:

-headless: kCGErrorRangeCheck : Window Server communications from  
outside of session allowed for root and console user only

After a bit of research, I realize that the "kCGErrorRangeCheck"  
happens whenever you use a Carbon framework. It pretty much is non-
avoidable unless you are using pure cocoa or unix frameworks. The  
Carbon stuff calls initialization bits that require a window server.  
According to this link - http://www.smalltalkconsulting.com/ 
squeak.html - A pure Cocoa version is in the works but not out now.

Please, if someone hears my call enlighten me. It shouldn't be this  
hard. My current tact is to download the source for the VM and see if  
there are options to be set that disable the window server  
completely. Does this sound feasible? I hope so, it's the only  
shimmer of light I can grasp for. That or just build a linux box to  
run Squeak...

Any and all tips appreciated,
-- Aaron


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

johnmci
LSBackgroundOnly  ok let me look at that logic.
Yes it appears you must pass in your wish to make the vm -headless via  
the command line.
Otherwise it will switch the LSBackgroundOnly to no so that the  
application icon will appear in the doc
If you set LSBackgroundOnly to yes and pass in -headless then it will  
run headless and not appear in the dock.

  In trying this I had to do

./Squeak\ VM\ Opt.app/Contents/MacOS/Squeak\ VM\ Opt -headless  
Squeakx.image

so you need to indicate both headless and where the image is, and set  
LSBackgroundOnly  to YES

However I did not check this outside of having a user logon.

Also see
http://developer.apple.com/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html#/ 
/apple_ref/doc/uid/TP30000999-CH202-DontLinkElementID_3
and maybe
http://developer.apple.com/technotes/tn2002/tn2062.html


You know your other choice is you can use the unix version of the  
squeak vm that has been compiled to run on os-x.

On 1-Aug-09, at 3:44 PM, Aaron Rosenzweig wrote:

> I'd like to thank Mariano, John, and Randal for giving me pointers,
>
> Please someone correct me if I am wrong but I believe it is  
> *impossible* to run Squeak headless in a nice manner on Mac OS X  
> with the ready made VMs that are available for download.
>
> LSBackgroundOnly - setting this property to "true" in the plist file  
> seems to have no effect.
>
> Using "-headless" from the command line and specifying the path to  
> the smalltalk image works like a charm but *only* from a terminal  
> window... which is pretty useless... Because if I'm doing it there I  
> might was well double click the .app bundle and have all the bells  
> and whistles in a GUI environment.
>
> The idea is to use launchctl to control the startup and shutdown of  
> the daemon Squeak process without a user even having to login. When  
> I try to launch it this way (as the "appserver" user) I get this  
> error in the unix system console:
>
> -headless: kCGErrorRangeCheck : Window Server communications from  
> outside of session allowed for root and console user only
>
> After a bit of research, I realize that the "kCGErrorRangeCheck"  
> happens whenever you use a Carbon framework. It pretty much is non-
> avoidable unless you are using pure cocoa or unix frameworks. The  
> Carbon stuff calls initialization bits that require a window server.  
> According to this link - http://www.smalltalkconsulting.com/squeak.html 
>  - A pure Cocoa version is in the works but not out now.
>
> Please, if someone hears my call enlighten me. It shouldn't be this  
> hard. My current tact is to download the source for the VM and see  
> if there are options to be set that disable the window server  
> completely. Does this sound feasible? I hope so, it's the only  
> shimmer of light I can grasp for. That or just build a linux box to  
> run Squeak...
>
> Any and all tips appreciated,
> -- Aaron
>
>
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>   Twitter:  
squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================




_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

Aaron Rosenzweig-2
Thanks John,

Actually I found that it didn't seem to matter much what the value of  
LSBackgroundOnly was. Just starting up from the command line in  
terminal with the option "-headless" was enough to have it come up  
without a GUI (in OS 10.4 Tiger).

I went to: http://www.squeak.org/Download/

Somehow my eyes missed the link to the pre-compiled unix binaries for  
OS X. Thanks for alerting me that they are there, I see them now. I  
guess because they weren't listed in the Mac section but in the  
general unix section I glossed over them. Anyway, I downloaded the  
unix source from there and compiled. Wow! it was really easy and  
really fast. I passed the following line to configure before I compiled:

../platforms/unix/config/configure --without-quartz --without-x

after doing "make" and "make install" I ran the following to test it  
out from the terminal first:

squeak -vm-display-null -vm-sound-null -headless /Applications/
Pier-1.2.app/Contents/Resources/pier.image

Unfortunately I got hit with:

This interpreter (vers. 6502) cannot read image file (vers. 6504).
Press CR to quit...

You see, I downloaded the Pier one-click-install bundle from the  
piercms website... as Pier is really the product I want to play with  
most at this moment and I figure this image would be the most up to  
date. But now digging under the covers it appears that maybe this one-
click install does not use true Squeak but the new "Pharo" VM?

Many thanks,
-- Aaron

On Aug 1, 2009, at 8:20 PM, John M McIntosh wrote:

> LSBackgroundOnly  ok let me look at that logic.
> Yes it appears you must pass in your wish to make the vm -headless  
> via the command line.
> Otherwise it will switch the LSBackgroundOnly to no so that the  
> application icon will appear in the doc
> If you set LSBackgroundOnly to yes and pass in -headless then it  
> will run headless and not appear in the dock.
>
>  In trying this I had to do
>
> ./Squeak\ VM\ Opt.app/Contents/MacOS/Squeak\ VM\ Opt -headless  
> Squeakx.image
>
> so you need to indicate both headless and where the image is, and  
> set LSBackgroundOnly  to YES
>
> However I did not check this outside of having a user logon.
>
> Also see
> http://developer.apple.com/documentation/Carbon/Conceptual/ 
> LaunchServicesConcepts/LSCConcepts/LSCConcepts.html#//apple_ref/doc/
> uid/TP30000999-CH202-DontLinkElementID_3
> and maybe
> http://developer.apple.com/technotes/tn2002/tn2062.html
>
>
> You know your other choice is you can use the unix version of the  
> squeak vm that has been compiled to run on os-x.
>
>
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

Aaron Rosenzweig-2
Hi Everyone,

Ok, I looked briefly at the Pharo VM source but it didn't seem nearly  
as easy to build as the Squeak one. So I gave up on it for the moment.

I decided to try a Squeak VM with a Squeak developer image that  
already had Pier on it (albeit an older version... but that should be  
upgradeable...). I'm able to double click and get it to launch and  
then confirm in my web browser that Pier is alive and well.  
Unfortunately when I try to do it from the command line it appears to  
hang. No errors, warnings, etc. But I can't access Pier through my  
web browser. It certainly appears that it "halfway" started up.

When I try to do it from launchctl it keeps aborting and after 10  
tries gives up. The console looks like this:

Aug  1 21:57:51 Super-Lan-Boy sudo:  recurve : TTY=ttyp2 ; PWD=/
Library/LaunchDaemons ; USER=root ; COMMAND=/bin/launchctl load /
Library/LaunchDaemons/com.squeak.seaside.plist
Aug  1 21:57:51 Super-Lan-Boy launchd: com.squeak.seaside: exited  
abnormally: Abort trap
Aug  1 21:57:51 Super-Lan-Boy launchd: com.squeak.seaside: respawning  
too quickly! throttling
Aug  1 21:57:51 Super-Lan-Boy launchd: com.squeak.seaside: 9 more  
failures without living at least 60 seconds will cause job removal
... keeps going until finally...
Aug  1 21:59:11 Super-Lan-Boy launchd: com.squeak.seaside: will  
restart in 10 seconds
Aug  1 21:59:21 Super-Lan-Boy launchd: com.squeak.seaside: exited  
abnormally: Abort trap
Aug  1 21:59:21 Super-Lan-Boy launchd: com.squeak.seaside: respawning  
too quickly! throttling
Aug  1 21:59:21 Super-Lan-Boy launchd: com.squeak.seaside: too many  
failures in succession

For the curious, here is what my launchctl plist looks like at the  
moment:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <false/>
        <key>GroupName</key>
        <string>appserverusr</string>
        <key>Label</key>
        <string>com.squeak.seaside</string>
        <key>OnDemand</key>
        <false/>
        <key>Program</key>
        <string>/usr/local/bin/squeak</string>
        <key>ProgramArguments</key>
        <array>
                <string>-vm-display-null</string>
                <string>-vm-sound-null</string>
                <string>-headless</string>
                <string>/Applications/Smalltalk/Seaside-2/Seaside-2.8-573.image</
string>
        </array>
        <key>ServiceIPC</key>
        <false/>
        <key>UserName</key>
        <string>appserver</string>
</dict>
</plist>

Then you attempt to invoke it with:

sudo launchctl load /Library/LaunchDaemons/com.squeak.seaside.plist

Cheers,
-- Aaron

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

johnmci
In reply to this post by Aaron Rosenzweig-2
The squeak VM and the pharo VM use the same source tree, just at  
different times

The Pharo VM uses the *latest* VM source tree which includes the  
Closure logic.
When you take an image and make it Closure aware and save it, then it  
becomes a image format of 6504, versus the older 6502.

When you build the squeak unix VM I think it uses an REALLY OLD source  
tree. What you need to do is build a new VM source tree using
VMMaker and use the latest MC change set.  Then replace the old source  
tree with the new one you create out of VMMaker.
The macintosh platform tree  see platforms/Mac OS/vm/Documentation/
readme.txt  has some notes about building the macintosh VM using VMMaker
which might prove useful.

In you other note: "9 more failures without living at least 60 seconds  
will cause job removal"

Something is causing the VM to die, then launchctl is restarting, but  
too frequently and you're curtains.

I'd suggest creating a new unix vm from the latest VMMaker.   Ask on  
the [hidden email] if you can't get the process to  
work for unix.

On 1-Aug-09, at 6:03 PM, Aaron Rosenzweig wrote:

> Thanks John,
>
> Actually I found that it didn't seem to matter much what the value  
> of LSBackgroundOnly was. Just starting up from the command line in  
> terminal with the option "-headless" was enough to have it come up  
> without a GUI (in OS 10.4 Tiger).
>
> I went to: http://www.squeak.org/Download/
>
> Somehow my eyes missed the link to the pre-compiled unix binaries  
> for OS X. Thanks for alerting me that they are there, I see them  
> now. I guess because they weren't listed in the Mac section but in  
> the general unix section I glossed over them. Anyway, I downloaded  
> the unix source from there and compiled. Wow! it was really easy and  
> really fast. I passed the following line to configure before I  
> compiled:
>
> ../platforms/unix/config/configure --without-quartz --without-x
>
> after doing "make" and "make install" I ran the following to test it  
> out from the terminal first:
>
> squeak -vm-display-null -vm-sound-null -headless /Applications/
> Pier-1.2.app/Contents/Resources/pier.image
>
> Unfortunately I got hit with:
>
> This interpreter (vers. 6502) cannot read image file (vers. 6504).
> Press CR to quit...
>
> You see, I downloaded the Pier one-click-install bundle from the  
> piercms website... as Pier is really the product I want to play with  
> most at this moment and I figure this image would be the most up to  
> date. But now digging under the covers it appears that maybe this  
> one-click install does not use true Squeak but the new "Pharo" VM?
>
> Many thanks,
> -- Aaron

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>   Twitter:  
squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================




_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Headless on Mac OS X

Aaron Rosenzweig-2
Stop the presses! I got it working :-)

Sorry for cross posting. I'll write it up in more detail later, on my  
own Pier installation even! But here's the rough notes at the moment:

1) I'm on Mac OS 10.4 Tiger on Intel
2) I downloaded the Pier 1.2 one-click install from www.piercms.com  
that is running on Pharo VM I believe
3) I enabled LSBackgroundOnly = true in the "info.plist" file inside  
the .app bundle resources - The purpose of this is to not let the app  
startup in the dock... I had somehow missed this before because my  
dock is normally hidden.
4) Needed to use "-headless" option as that is the only one that  
works with this vm. The -vm-display-null option does not work.

Here's the command I use to load into launchd:

sudo launchctl load /Library/LaunchDaemons/com.squeak.seaside.plist

(That also shows the path to where I put the custom plist file in for  
launchd).

Below is the contents of the launchd plist file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <false/>
        <key>Label</key>
        <string>com.squeak.seaside</string>
        <key>OnDemand</key>
        <false/>
        <key>ProgramArguments</key>
        <array>
                <string>/Applications/Smalltalk/Pier-1.2.app/Contents/MacOS/Squeak  
VM Opt</string>
                <string>-headless</string>
                <string>/Applications/Smalltalk/Pier-1.2.app/Contents/Resources/
pier.image</string>
        </array>
         <key>ServiceIPC</key>
         <false/>
         <key>StandardErrorPath</key>
         <string>/Library/Logs/com.squeak.seaside.log</string>
         <key>StandardOutPath</key>
         <string>/Library/Logs/com.squeak.seaside.log</string>
        <key>UserName</key>
        <string>root</string>
</dict>
</plist>

Again, I'll write more later, and clarify once I get Pier set up on  
the desired server Mac.

Thanks everyone,
-- Aaron
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Detailed instructions: Pier Headless on Mac OS X

Aaron Rosenzweig-2
In reply to this post by johnmci
Hello Everyone,

I've outlined detailed instructions on how to get Pier up and running  
as a server process on Mac OS X:

http://www.somethingiknow.com/aaronCorner/aaronSoftwareBlog/ 
Pier_headless_on_Mac_OS_X

Kudos to everyone who has ever contributed to Pier. I was impressed  
to see sessionless URLs working out-of-the-box. It's a fiendishly  
clever application.

Thank you for allowing people like me to partake in your glory,
-- Aaron
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Detailed instructions: Pier Headless on Mac OS X

Lukas Renggli
Thank your for this excellent write-up. I linked your article from
<http://www.piercms.com/doc/deploy>. Also I added your site to the
list of known Pier installations. I hope you don't mind?

Cheers,
Lukas

2009/8/6 Aaron Rosenzweig <[hidden email]>:

> Hello Everyone,
>
> I've outlined detailed instructions on how to get Pier up and running as a
> server process on Mac OS X:
>
> http://www.somethingiknow.com/aaronCorner/aaronSoftwareBlog/Pier_headless_on_Mac_OS_X
>
> Kudos to everyone who has ever contributed to Pier. I was impressed to see
> sessionless URLs working out-of-the-box. It's a fiendishly clever
> application.
>
> Thank you for allowing people like me to partake in your glory,
> -- Aaron
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>



--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki