Am 07.08.2009 um 07:45 schrieb Chuck Hill:

Yes, I know how to get a thread dump. There are many tools. The question is why the simple, basic kill -QUIT is not working for deployed apps on Leopard.

Works for me (wonder wotaskd, custom launchd script). Dunno if the launch script influences it.

Cheers, Anjo

s11:~ root# cat /Library/LaunchDaemons/ch.aximus.wotaskd.plist
<?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>
        <true/>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>ch.aximus.wotaskd</string>
        <key>Program</key>
        <string>/usr/local/bin/startWOtaskd.rb</string>
        <key>ProgramArguments</key>
        <array>
                <string>wotaskd</string>
                <string>wotaskd</string>
                <string>-WOPort</string>
                <string>1085</string>
        </array>
</dict>
</plist>

s11:~ root# cat /usr/local/bin/startWOtaskd.rb
#!/usr/bin/env ruby
# (2008-Dec-08)

$:.push("/usr/local/etc")
require 'siteconfig'

counter = 1
threshold = 6
logfile = "/Work/Logs/Apps/wotaskd.out"
program = File.basename($0)
defaultPath = "/System/Library/WebObjects/JavaApplications/wotaskd.woa/"
user = "appserver"
$pid = nil

if ARGV.size == 0
        puts "Usage: #{program} path_to_wotaskd [arguments]"
        puts "Example:\n   #{program} wotaskd -WOPort 1085"
        puts "The program will be started under user '#{user}'"
        puts "Default path: #{defaultPath}  (if path_to_wotaskd is relative)"
        puts "Logfile: #{logfile}"
        exit 1
end

wotaskd = ARGV.shift
wotaskd = defaultPath + wotaskd unless wotaskd =~ /^\//
args = ARGV.join(" ")
unless File.exist?(wotaskd)
  puts "ERROR. File not found: #{wotaskd}   (ARGS= #{args} )"
  exit 1
end
command = "sudo -u #{user} #{wotaskd} #{args}"


stdout = nil    # set to "stdout" for debug output
$SYSLOG = SysLogger.new("startWOtaskd", 5, stdout, "syslog")

trap("TERM") {   # TERM is the default kill signal
        if $pid != nil && $pid > 100
          $SYSLOG.notice "SIGTERM received. Stopping wotaskd (pid=#{$pid})."
          Process.kill("SIGTERM", $pid)
        end
        exit 0
}

while (counter <= threshold)
        if ($pid = fork) == nil
           outfile = File.new(logfile, "a")
outfile.puts "\nNEWRUN (Pid=#{$$} Counter=#{counter}) #{`date`}"
           outfile.puts "COMMAND: #{command}"
           $stdout.reopen(outfile)
           $stderr.reopen(outfile)
           exec(command)
        else
$SYSLOG.notice "STARTING wotaskd (Pid=#{$pid} Counter=#{counter}). Logfile= #{logfile}"
           Process.wait
        end     
        counter = counter + 1
        sleep 10
end

$SYSLOG.error "Restart threshold reached. Did restart wotaskd #{threshold} times, giving up."

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to