Hudson-ci refuses to launch screen on OSX
I have a very i开发者_开发百科ntermittent issue (and now constant failure) launching gnu-screen on OSX from hudson. I have a shell script that does just this:
#!/bin/bash
screen -dm -S foobar
From the command-line as the hudson user this works just fine, and this screen session show up with screen -ls. From the hudson task this does not work. It used to work for a few hours and I have no idea why it does not work any more.
What I've tried so far:
- Put the screen command into a separate bash script. Eg. /tmp/foo.sh
- Put path prefixes in case the screen command is not found. But screen -ls works just fine, so that's not it
- Run screen in non-detached mode, just as a test. This fails as expected with "Must be connected to a terminal.". So this means that screen at least is thinking of doing the right thing.
- Run screen as a LaunchDaemon that i start with a launchctl (create the plist file as OnDemand). Same problem.
Is there some way I can debug what's going on? I can't think of how to figure out why things are not working and I'm completely out of ideas. And I don't see any logs that might help either.
My System is: OSX 10.6.5; screen ver. 4.00.03
Update: I just thought to look in /var/log/system.log and I see:
Feb 24 23:19:00 macmini2 com.apple.launchd[1] (0x1037c0.anonymous.screen[57291]): Switching sessions is not allowed in the system Mach bootstrap.
Feb 24 23:19:00 macmini2 com.apple.launchd[1] (0x1037c0.anonymous.screen[57291]): _vprocmgr_switch_to_session(): kr = 0x44c
I'm going to have to research this further it seems, but I don't want to go down the path suggested in my first couple of searches for this error, which are to install fink version of screen, or to build screen from source. I'd rather keep the machine as is if at all possible (though I'm not against compiling screen from source if that's the only solution).
I've found a solution to my problem, and I suspect it's bad protocol to answer my own question, but for the sake of others who may have this issue, here's how I got around this ..
The easiest/only solution seems to be to build screen from source. Steps are very simple and straight-forward:
git clone git://git.savannah.gnu.org/screen.git
cd screen/ && ./mktar.pl && tar xfz screen-4.1.0.tar.gz
cd screen-4.1.0
./autogen.sh && ./configure && make
sudo cp screen /usr/local/bin/
/usr/local/bin/screen --version
Using this new screen for all daemons or background processes (eg. Hudson's shell launcher, cron'ed tasks that try to use screen, etc.) works very smoothly. This also keeps the system screen (/usr/bin/screen) unaltered.
References:
- This apple forum thread is what gave me the idea to build from source.
- I just found this stackoverflow solution. It's basically the same solution, so I've voted it up.
精彩评论