从 ruby​​ 守护程序中调试 osascript 执行

发布于 2024-10-14 02:58:16 字数 25780 浏览 6 评论 0原文

我需要经常在我的网络服务器上运行 applescript。由于服务器正在运行 Rails,并且我需要在运行脚本之前和之后访问我的模型,我认为守护进程(通过 daemons gem) 可能是合适的。

从理论上讲,这相当容易。下面是一个简化的示例。

#!/usr/bin/env ruby

ENV["RAILS_ENV"] ||= "development"

require File.dirname(__FILE__) + "/../../config/application"
Rails.application.require_environment!

$running = true
Signal.trap("TERM") do 
  $running = false
end

while($running) do

  Rails.logger.info "Daemon running at #{Time.now}.\n"

  # sanity check
  %x{touch /foo.txt}

  # this stops working after a while
  result = %x{/usr/bin/osascript -s o /path/to/the/script.scpt}

  # under normal operation, my applescript spits out a string result
  Rails.logger.info "Result: #{result}.\n"

  sleep 30
end

出于测试目的,我用一行代码替换了(有点长且耗时的)生产苹果脚本。这就是它的全部荣耀:

"It Worked!"

因为 applescript 将脚本的最后一行视为返回语句,所以该字符串被传递到我的 result 变量中并最终登录到 Rails 中。

这很有效——暂时有效。但最终(通常在几个小时后)osascript 行停止返回结果。守护进程仍在运行,但据我所知,osascript 行完全失败,没有任何解释。

我可以肯定地说,守护进程本身并没有死亡,因为

  • Rails 日志条目以正确的间隔出现,并且
  • 我对“foo.txt”的健全性检查定期更新其最后修改的时间戳。

我想我应该发布一个更新,以防有人遇到类似的问题。首先,我找到了一个解决方法。这确实是一个丑陋的黑客攻击,但它可以完成工作,并且不会每 2 小时崩溃一次。我正在做的是每次运行作业时建立一个 ssh 连接,这有效地让脚本在干净的会话上运行。

Net::SSH.start('127.0.0.1', 'username', :password => 'password') do |ssh|
  result = ssh.exec!('/usr/bin/osascript -s o /path/to/the/script.scpt') 
end

其次,我在 ~/Library/Logs/DiagnosticReports 目录中发现了大量崩溃报告。我越来越相信这整个考验与某种会话超时或过期有关。

Process:         osascript [24884]
Path:            /usr/bin/osascript
Identifier:      osascript
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  ruby [24868]

Date/Time:       2011-02-03 16:40:28.526 -0500
OS Version:      Mac OS X 10.6.6 (10J567)
Report Version:  6

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
abort() called
LaunchServices: GetOurLSSessionIDInit() returned err #1, securitySessionID == 0x0, vers=10600000 uid=501 euid=501web1.local] [Se
/Users/greg/Applescript/fbbuildutil.scpt

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib               0x00007fff86fd6616 __kill + 10
1   libSystem.B.dylib               0x00007fff87076cca abort + 83
2   com.apple.LaunchServices        0x00007fff82faec84 GetOurLSSessionIDInit() + 298
3   libSystem.B.dylib               0x00007fff86fa08da pthread_once + 95
4   com.apple.LaunchServices        0x00007fff82faf29b SetupCoreApplicationServicesCommunicationPort() + 1343
5   com.apple.LaunchServices        0x00007fff82faf68d getProcessDispatchTable() + 19
6   com.apple.LaunchServices        0x00007fff82fb17a5 LSClientSideSharedMemory::GetClientSideSharedMemory(LSSessionID, bool) + 187
7   com.apple.LaunchServices        0x00007fff82fb1e87 _LSCopyApplicationInformationItem + 43
8   com.apple.AE                    0x00007fff8722b735 aeGetThisProcess() + 49
9   com.apple.AE                    0x00007fff8722b6df AEEventImpl::initializeData() + 89
10  com.apple.AE                    0x00007fff8722b5c4 AEEventImpl::AEEventImpl(unsigned int, unsigned int, AEDesc const*, short, int) + 76
11  com.apple.AE                    0x00007fff8722f33e AECreateAppleEvent + 88
12  osascript                       0x0000000100001a42 0x100000000 + 6722
13  osascript                       0x0000000100000fa0 0x100000000 + 4000

Thread 1:  Dispatch queue: com.apple.libdispatch-manager
0   libSystem.B.dylib               0x00007fff86fa116a kevent + 10
1   libSystem.B.dylib               0x00007fff86fa303d _dispatch_mgr_invoke + 154
2   libSystem.B.dylib               0x00007fff86fa2d14 _dispatch_queue_invoke + 185
3   libSystem.B.dylib               0x00007fff86fa283e _dispatch_worker_thread2 + 252
4   libSystem.B.dylib               0x00007fff86fa2168 _pthread_wqthread + 353
5   libSystem.B.dylib               0x00007fff86fa2005 start_wqthread + 13

Thread 2:
0   libSystem.B.dylib               0x00007fff86fa1f8a __workq_kernreturn + 10
1   libSystem.B.dylib               0x00007fff86fa239c _pthread_wqthread + 917
2   libSystem.B.dylib               0x00007fff86fa2005 start_wqthread + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00000000000001f5  rcx: 0x00007fff5fbfb378  rdx: 0x0000000000000000
  rdi: 0x0000000000006134  rsi: 0x0000000000000006  rbp: 0x00007fff5fbfb390  rsp: 0x00007fff5fbfb378
   r8: 0x000000010011d740   r9: 0x00000001001fc0a4  r10: 0x00007fff86fd2656  r11: 0x0000000000000202
  r12: 0x00007fff5fbfb3c0  r13: 0x00007fff703ce328  r14: 0x00007fff82faeb5a  r15: 0x00007fff70c465c0
  rip: 0x00007fff86fd6616  rfl: 0x0000000000000202  cr2: 0x00000001000f8000

Binary Images:
       0x100000000 -        0x100002ff7 +osascript ??? (???) <1B4A05C4-8772-DCFD-444F-31FEE356E299> /usr/bin/osascript
       0x1000f1000 -        0x1000f1fff  com.apple.applescript.component 2.1.2 (2.1.2) <C621AB4A-9C10-7F1D-6B4E-0B15373D5C59> /System/Library/Components/AppleScript.component/Contents/MacOS/AppleScript
       0x100419000 -        0x1004adfe7  com.apple.applescript 2.1.2 (2.1.2) <E9C125A4-8743-6BF8-5A05-BE85778D4158> /System/Library/PrivateFrameworks/AppleScript.framework/Versions/A/AppleScript
    0x7fff5fc00000 -     0x7fff5fc3bdef  dyld 132.1 (???) <486E6C61-1197-CC7C-2197-82CE505102D7> /usr/lib/dyld
    0x7fff8011d000 -     0x7fff8011efff  liblangid.dylib ??? (???) <EA4D1607-2BD5-2EE2-2A3B-632EEE5A444D> /usr/lib/liblangid.dylib
    0x7fff8016d000 -     0x7fff8046bfe7  com.apple.HIToolbox 1.6.4 (???) <263AD497-F4CC-9610-E7D3-B95CF6F02030> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x7fff80472000 -     0x7fff804befff  libauto.dylib ??? (???) <F7221B46-DC4F-3153-CE61-7F52C8C293CF> /usr/lib/libauto.dylib
    0x7fff804bf000 -     0x7fff80574fe7  com.apple.ink.framework 1.3.3 (107) <8C36373C-5473-3A6A-4972-BC29D504250F> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
    0x7fff8071a000 -     0x7fff80784fe7  libvMisc.dylib 268.0.1 (compatibility 1.0.0) <AF0EA96D-000F-8C12-B952-CB7E00566E08> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x7fff80791000 -     0x7fff80794ff7  com.apple.securityhi 4.0 (36638) <87868A3E-9341-1078-F00C-5E5972F01A4A> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
    0x7fff80795000 -     0x7fff808aefef  libGLProgrammability.dylib ??? (???) <4F2DC233-7DD2-1204-CAA5-3E6524F0AB75> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
    0x7fff808b0000 -     0x7fff8092dfef  libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
    0x7fff80949000 -     0x7fff80949ff7  com.apple.ApplicationServices 38 (38) <10A0B9E9-4988-03D4-FC56-DDE231A02C63> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
    0x7fff80a2b000 -     0x7fff80ba2fe7  com.apple.CoreFoundation 6.6.4 (550.42) <770C572A-CF70-168F-F43C-242B9114FCB5> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff80ba3000 -     0x7fff813adfe7  libBLAS.dylib 219.0.0 (compatibility 1.0.0) <FC941ECB-71D0-FAE3-DCBF-C5A619E594B8> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x7fff813ae000 -     0x7fff813b4ff7  com.apple.DiskArbitration 2.3 (2.3) <857F6E43-1EF4-7D53-351B-10DE0A8F992A> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x7fff813e6000 -     0x7fff813e9ff7  libCoreVMClient.dylib ??? (???) <609598E6-195D-E5D4-3B92-AE8D9768829C> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
    0x7fff813ea000 -     0x7fff813fefff  libGL.dylib ??? (???) <1EB1BD0F-C17F-55DF-B8B4-8E9CF99359D4> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
    0x7fff81480000 -     0x7fff814b9fef  libcups.2.dylib 2.8.0 (compatibility 2.0.0) <561D0DCB-47AD-A12C-9066-70E4CBAD331C> /usr/lib/libcups.2.dylib
    0x7fff816aa000 -     0x7fff816f4ff7  com.apple.Metadata 10.6.3 (507.15) <5170FCE0-ED6C-2E3E-AB28-1DDE3F628FC5> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x7fff8185b000 -     0x7fff81876ff7  com.apple.openscripting 1.3.1 (???) <9D50701D-54AC-405B-CC65-026FCB28258B> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
    0x7fff818b9000 -     0x7fff81901ff7  libvDSP.dylib 268.0.1 (compatibility 1.0.0) <98FC4457-F405-0262-00F7-56119CA107B6> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x7fff81940000 -     0x7fff8194ffff  com.apple.NetFS 3.2.1 (3.2.1) <E5D33870-27D2-E50B-9B35-16AA50369733> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
    0x7fff81950000 -     0x7fff81a67fef  libxml2.2.dylib 10.3.0 (compatibility 10.0.0) <B2FB9DA8-6EC9-FFBC-C919-C022B9CBEB73> /usr/lib/libxml2.2.dylib
    0x7fff81a98000 -     0x7fff81b51fff  libsqlite3.dylib 9.6.0 (compatibility 9.0.0) <2C5ED312-E646-9ADE-73A9-6199A2A43150> /usr/lib/libsqlite3.dylib
    0x7fff81b52000 -     0x7fff81c07fe7  com.apple.ColorSync 4.6.3 (4.6.3) <5A7360A8-D495-1E8D-C4B4-A363AF989ADE> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
    0x7fff81c08000 -     0x7fff81c33ff7  libxslt.1.dylib 3.24.0 (compatibility 3.0.0) <87A0B228-B24A-C426-C3FB-B40D7258DD49> /usr/lib/libxslt.1.dylib
    0x7fff81e28000 -     0x7fff81e59fff  libGLImage.dylib ??? (???) <1A8E58CF-FA2F-14F7-A097-D34EEA8A7D03> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
    0x7fff81e5a000 -     0x7fff81e6cfe7  libsasl2.2.dylib 3.15.0 (compatibility 3.0.0) <76B83C8D-8EFE-4467-0F75-275648AFED97> /usr/lib/libsasl2.2.dylib
    0x7fff81e6d000 -     0x7fff81f2aff7  com.apple.CoreServices.OSServices 357 (357) <7B22626F-D544-1955-CC53-240F4CACEB4A> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x7fff81f2b000 -     0x7fff81f30ff7  com.apple.CommonPanels 1.2.4 (91) <4D84803B-BD06-D80E-15AE-EFBE43F93605> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
    0x7fff81f47000 -     0x7fff81f6ffff  com.apple.DictionaryServices 1.1.2 (1.1.2) <E9269069-93FA-2B71-F9BA-FDDD23C4A65E> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    0x7fff81fce000 -     0x7fff81fceff7  com.apple.Carbon 150 (152) <191B4F4B-8D06-796B-CA0C-782F06DD7BC7> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
    0x7fff81fe1000 -     0x7fff81fe4fff  com.apple.help 1.3.1 (41) <54B79BA2-B71B-268E-8752-5C8EE00E49E4> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
    0x7fff81fe5000 -     0x7fff81ff9ff7  com.apple.speech.synthesis.framework 3.10.35 (3.10.35) <621B7415-A0B9-07A7-F313-36BEEDD7B132> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
    0x7fff81ffa000 -     0x7fff8201dfff  com.apple.opencl 12.3 (12.3) <D30A45FC-4520-45AF-3CA5-092313DB5D54> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
    0x7fff8201e000 -     0x7fff82024ff7  com.apple.CommerceCore 1.0 (6) <E8A1144C-5666-9840-4729-256FE69CDBDB> /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/CommerceCore.framework/Versions/A/CommerceCore
    0x7fff82073000 -     0x7fff82088ff7  com.apple.LangAnalysis 1.6.6 (1.6.6) <1AE1FE8F-2204-4410-C94E-0E93B003BEDA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
    0x7fff82107000 -     0x7fff82148fff  com.apple.SystemConfiguration 1.10.5 (1.10.2) <FB39F09C-57BB-D8CC-348D-93E00C602F7D> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x7fff82149000 -     0x7fff823cffff  com.apple.security 6.1.1 (37594) <1B4E1ABD-1BB3-DA49-F574-0EEB23E73C6A> /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x7fff825d4000 -     0x7fff825d5ff7  com.apple.audio.units.AudioUnit 1.6.5 (1.6.5) <14F14B5E-9287-BC36-0C3F-6592E6696CD4> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
    0x7fff825d6000 -     0x7fff825e5fff  com.apple.opengl 1.6.12 (1.6.12) <DE3F0528-7759-CDFD-A2CF-C51D3C9C8B39> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
    0x7fff825e6000 -     0x7fff8269cfff  libobjc.A.dylib 227.0.0 (compatibility 1.0.0) <99CB3A0F-64CF-1D16-70CD-8AED2EF06C30> /usr/lib/libobjc.A.dylib
    0x7fff8269d000 -     0x7fff826fdfe7  com.apple.framework.IOKit 2.0 (???) <D107CB8A-5182-3AC4-35D0-07068A695C05> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x7fff8287e000 -     0x7fff828a4fe7  libJPEG.dylib ??? (???) <DFA5DAC2-D1C6-D5ED-F95D-AC185E98B6E7> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
    0x7fff828eb000 -     0x7fff82c1ffff  com.apple.CoreServices.CarbonCore 861.23 (861.23) <96465459-6536-3FD7-7504-B59D0390EEC5> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x7fff82ca9000 -     0x7fff82d28fe7  com.apple.audio.CoreAudio 3.2.6 (3.2.6) <6D8AD3F7-409D-512C-C5BE-66C64D1B8F3E> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
    0x7fff82d29000 -     0x7fff82dd8fff  edu.mit.Kerberos 6.5.10 (6.5.10) <6A159CD8-5C02-4528-C36F-6AFBFD61576B> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
    0x7fff82fa2000 -     0x7fff83042fff  com.apple.LaunchServices 362.2 (362.2) <A8EDC37C-1D40-5ED0-49BE-90EF110A6B3A> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x7fff83055000 -     0x7fff83213fff  libicucore.A.dylib 40.0.0 (compatibility 1.0.0) <781E7B63-2AD0-E9BA-927C-4521DB616D02> /usr/lib/libicucore.A.dylib
    0x7fff83214000 -     0x7fff833cbfef  com.apple.ImageIO.framework 3.0.4 (3.0.4) <EE9DFBD6-6354-7C5A-F4C7-5FF782A7D992> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
    0x7fff833cc000 -     0x7fff833cdff7  libScreenReader.dylib ??? (???) <D98F32A6-4729-8040-AE06-76D2F4CF9BBB> /usr/lib/libScreenReader.dylib
    0x7fff833ce000 -     0x7fff833ceff7  com.apple.CoreServices 44 (44) <DC7400FB-851E-7B8A-5BF6-6F50094302FB> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x7fff8340c000 -     0x7fff8340dff7  com.apple.TrustEvaluationAgent 1.1 (1) <5952A9FA-BC2B-16EF-91A7-43902A5C07B6> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff8340e000 -     0x7fff83427fff  com.apple.CFOpenDirectory 10.6 (10.6) <CCF79716-7CC6-2520-C6EB-A4F56AD0A207> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
    0x7fff83428000 -     0x7fff834a6fff  com.apple.CoreText 3.5.0 (???) <4D5C7932-293B-17FF-7309-B580BB1953EA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
    0x7fff83730000 -     0x7fff83782ff7  com.apple.HIServices 1.8.2 (???) <7C91D07D-FA20-0882-632F-0CAE4FAC2B79> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
    0x7fff8381c000 -     0x7fff83942fff  com.apple.audio.toolbox.AudioToolbox 1.6.5 (1.6.5) <B51023BB-A5C9-3C65-268B-6B86B901BB2C> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
    0x7fff83943000 -     0x7fff83992ff7  com.apple.DirectoryService.PasswordServerFramework 6.0 (6.0) <FE549581-6A40-BD28-24A4-68FA0B616780> /System/Library/PrivateFrameworks/PasswordServer.framework/Versions/A/PasswordServer
    0x7fff83993000 -     0x7fff839a9fef  libbsm.0.dylib ??? (???) <42D3023A-A1F7-4121-6417-FCC6B51B3E90> /usr/lib/libbsm.0.dylib
    0x7fff839f7000 -     0x7fff83ac9fe7  com.apple.CFNetwork 454.11.5 (454.11.5) <5D68598D-C138-C8B6-B6AC-B1F48B01E021> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x7fff83bb1000 -     0x7fff83bb1ff7  com.apple.Accelerate 1.6 (Accelerate 1.6) <15DF8B4A-96B2-CB4E-368D-DEC7DF6B62BB> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x7fff83bb2000 -     0x7fff83c4cfff  com.apple.ApplicationServices.ATS 4.4 (???) <395849EE-244A-7323-6CBA-E71E3B722984> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
    0x7fff83c4d000 -     0x7fff83c63fff  com.apple.ImageCapture 6.0.1 (6.0.1) <09ABF2E9-D110-71A9-4A6F-8A61B683E936> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
    0x7fff84091000 -     0x7fff841b2fe7  libcrypto.0.9.8.dylib 0.9.8 (compatibility 0.9.8) <48AEAFE1-21F4-B3C8-4199-35AD5E8D0613> /usr/lib/libcrypto.0.9.8.dylib
    0x7fff841bb000 -     0x7fff841d1fe7  com.apple.MultitouchSupport.framework 207.10 (207.10) <458F0259-6EDC-16BA-E6AA-1CEED002D188> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
    0x7fff841e4000 -     0x7fff84269ff7  com.apple.print.framework.PrintCore 6.3 (312.7) <CDFE82DD-D811-A091-179F-6E76069B432D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
    0x7fff8426a000 -     0x7fff84607fe7  com.apple.QuartzCore 1.6.3 (227.34) <C4AABD56-8C93-BAD0-4B27-7E9A2F0EAEE4> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
    0x7fff8463e000 -     0x7fff8463eff7  com.apple.vecLib 3.6 (vecLib 3.6) <96FB6BAD-5568-C4E0-6FA7-02791A58B584> /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff84927000 -     0x7fff84932ff7  com.apple.speech.recognition.framework 3.11.1 (3.11.1) <3D65E89B-FFC6-4AAF-D5CC-104F967C8131> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
    0x7fff84d5e000 -     0x7fff84d63fff  libGIF.dylib ??? (???) <A7BF2D68-F489-720C-E5A9-DC2B24DC5A21> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
    0x7fff84da8000 -     0x7fff851ebfef  libLAPACK.dylib 219.0.0 (compatibility 1.0.0) <0CC61C98-FF51-67B3-F3D8-C5E430C201A9> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x7fff85efd000 -     0x7fff85f1dff7  com.apple.DirectoryService.Framework 3.6 (621.9) <E7AFAAFA-8221-585B-85D0-171ADC490825> /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService
    0x7fff85f1e000 -     0x7fff85f23fff  libGFXShared.dylib ??? (???) <991F8197-FD06-2AF1-F99B-E448ED4FB2AC> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
    0x7fff85f24000 -     0x7fff85ffeff7  com.apple.vImage 4.0 (4.0) <354F34BF-B221-A3C9-2CA7-9BE5E14AD5AD> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x7fff8603a000 -     0x7fff8673706f  com.apple.CoreGraphics 1.545.0 (???) <356D59D6-1DD1-8BFF-F9B3-1CE51D2F1EC7> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
    0x7fff86738000 -     0x7fff86738ff7  com.apple.Accelerate.vecLib 3.6 (vecLib 3.6) <4CCE5D69-F1B3-8FD3-1483-E0271DB2CCF3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff8687c000 -     0x7fff868c3ff7  com.apple.coreui 2 (114) <923E33CC-83FC-7D35-5603-FB8F348EE34B> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
    0x7fff86ab9000 -     0x7fff86b45fef  SecurityFoundation ??? (???) <F43FDB02-CAA5-F8FF-C8D7-6665E7403ECE> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
    0x7fff86b46000 -     0x7fff86b63ff7  libPng.dylib ??? (???) <667C3883-32A5-CCCC-8624-972B5DFD8EA4> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
    0x7fff86b89000 -     0x7fff86baafff  libresolv.9.dylib 41.0.0 (compatibility 1.0.0) <9F322F47-0584-CB7D-5B73-9EBD670851CD> /usr/lib/libresolv.9.dylib
    0x7fff86bab000 -     0x7fff86e2eff7  com.apple.Foundation 6.6.4 (751.42) <AF1E3050-3503-8714-8274-EA6BD6BE8A22> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x7fff86e2f000 -     0x7fff86f6dfff  com.apple.CoreData 102.1 (251) <9DFE798D-AA52-6A9A-924A-DA73CB94D81A> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x7fff86f87000 -     0x7fff87148fff  libSystem.B.dylib 125.2.1 (compatibility 1.0.0) <F00A8B2F-84A0-0868-1047-3A13F9114864> /usr/lib/libSystem.B.dylib
    0x7fff8718b000 -     0x7fff8718dfff  libRadiance.dylib ??? (???) <6C974488-62D2-71BA-A45E-C764A0AF7354> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
    0x7fff871de000 -     0x7fff8721ffef  com.apple.QD 3.36 (???) <5DC41E81-32C9-65B2-5528-B33E934D5BB4> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
    0x7fff87229000 -     0x7fff87264fff  com.apple.AE 496.4 (496.4) <55AAD5CA-7160-7899-1C68-562ED8160DF7> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x7fff8728f000 -     0x7fff87293ff7  libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
    0x7fff873bd000 -     0x7fff873ceff7  libz.1.dylib 1.2.3 (compatibility 1.0.0) <97019C74-161A-3488-41EC-A6CA8738418C> /usr/lib/libz.1.dylib
    0x7fff873cf000 -     0x7fff87418fef  libGLU.dylib ??? (???) <CCE779A9-2467-A5AA-A558-691E43A1105F> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
    0x7fff87419000 -     0x7fff8746eff7  com.apple.framework.familycontrols 2.0.2 (2020) <A3CFF697-B9DB-A7E5-3B39-9DA9B34F0595> /System/Library/PrivateFrameworks/FamilyControls.framework/Versions/A/FamilyControls
    0x7fff8746f000 -     0x7fff874fffff  com.apple.SearchKit 1.3.0 (1.3.0) <4175DC31-1506-228A-08FD-C704AC9DF642> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x7fff87528000 -     0x7fff875e9fe7  libFontParser.dylib ??? (???) <8B12D37E-3A95-5A73-509C-3AA991E0C546> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
    0x7fff8766e000 -     0x7fff876bdfef  libTIFF.dylib ??? (???) <176B52ED-4F6C-D0C2-EABC-C032BFC3DFAA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
    0x7fff876be000 -     0x7fff876c4ff7  IOSurface ??? (???) <EAD87C9F-BADC-7116-4ADD-0B0679459D24> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
    0x7fff87dce000 -     0x7fff87dd5fff  com.apple.OpenDirectory 10.6 (10.6) <4200CFB0-DBA1-62B8-7C7C-91446D89551F> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
    0x7fff87fba000 -     0x7fff8809ffef  com.apple.DesktopServices 1.5.9 (1.5.9) <27890B2C-0CD2-7C27-9D0C-D5952C5E8438> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
    0x7fff884b9000 -     0x7fff884c7ff7  libkxld.dylib ??? (???) <27713C39-0E51-8F5A-877B-C5539C96A520> /usr/lib/system/libkxld.dylib
    0x7fff884c8000 -     0x7fff88ebefff  com.apple.AppKit 6.6.7 (1038.35) <9F4DF818-9DB9-98DA-490C-EF29EA757A97> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7fff890fb000 -     0x7fff89120ff7  com.apple.CoreVideo 1.6.2 (45.6) <E138C8E7-3CB6-55A9-0A2C-B73FE63EA288> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
    0x7fff89121000 -     0x7fff89123fff  com.apple.print.framework.Print 6.1 (237.1) <CA8564FB-B366-7413-B12E-9892DA3C6157> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
    0x7fffffe00000 -     0x7fffffe01fff  libSystem.B.dylib ??? (???) <F00A8B2F-84A0-0868-1047-3A13F9114864> /usr/lib/libSystem.B.dylib

I have a need to frequently run an applescript on my web server. As the server is running rails, and I need access to my models before and after running the script, I thought that a daemon (via the daemons gem) might be appropriate.

In theory this is fairly easy. Below is a simplified example.

#!/usr/bin/env ruby

ENV["RAILS_ENV"] ||= "development"

require File.dirname(__FILE__) + "/../../config/application"
Rails.application.require_environment!

$running = true
Signal.trap("TERM") do 
  $running = false
end

while($running) do

  Rails.logger.info "Daemon running at #{Time.now}.\n"

  # sanity check
  %x{touch /foo.txt}

  # this stops working after a while
  result = %x{/usr/bin/osascript -s o /path/to/the/script.scpt}

  # under normal operation, my applescript spits out a string result
  Rails.logger.info "Result: #{result}.\n"

  sleep 30
end

For testing purposes I've replaced the (somewhat long and time consuming) production applescript with a one-liner. Here it is, in all its glory:

"It Worked!"

Because applescript treats the last line of the script as a return statement, this string gets passed into my result variable and ultimately logged in rails.

This works great - for a while. Eventually though (typically after several hours) the osascript line stops returning results. The daemon is still running but the osascript line, for all I can tell, is completely failing without explanation.

I can say with certainty that the daemon itself has not died because

  • The rails log entries appear at correct intervals, and
  • My sanity check of "foo.txt" regularly updates its last modified time stamp.

I thought I'd post an update to this in case anyone out there is having a similar problem. First off, I've found a workaround. Its an ugly hack for sure, but it gets the job done and it doesn't crash every 2 hours. What I'm doing is establishing an ssh connection every time the job is run, which effectively lets the script run on a clean session.

Net::SSH.start('127.0.0.1', 'username', :password => 'password') do |ssh|
  result = ssh.exec!('/usr/bin/osascript -s o /path/to/the/script.scpt') 
end

And secondly, I've found a large number of crash reports in my ~/Library/Logs/DiagnosticReports directory. More and more I'm starting to believe that this whole ordeal has to do with some kind of session timeout or expiration.

Process:         osascript [24884]
Path:            /usr/bin/osascript
Identifier:      osascript
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  ruby [24868]

Date/Time:       2011-02-03 16:40:28.526 -0500
OS Version:      Mac OS X 10.6.6 (10J567)
Report Version:  6

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
abort() called
LaunchServices: GetOurLSSessionIDInit() returned err #1, securitySessionID == 0x0, vers=10600000 uid=501 euid=501web1.local] [Se
/Users/greg/Applescript/fbbuildutil.scpt

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib               0x00007fff86fd6616 __kill + 10
1   libSystem.B.dylib               0x00007fff87076cca abort + 83
2   com.apple.LaunchServices        0x00007fff82faec84 GetOurLSSessionIDInit() + 298
3   libSystem.B.dylib               0x00007fff86fa08da pthread_once + 95
4   com.apple.LaunchServices        0x00007fff82faf29b SetupCoreApplicationServicesCommunicationPort() + 1343
5   com.apple.LaunchServices        0x00007fff82faf68d getProcessDispatchTable() + 19
6   com.apple.LaunchServices        0x00007fff82fb17a5 LSClientSideSharedMemory::GetClientSideSharedMemory(LSSessionID, bool) + 187
7   com.apple.LaunchServices        0x00007fff82fb1e87 _LSCopyApplicationInformationItem + 43
8   com.apple.AE                    0x00007fff8722b735 aeGetThisProcess() + 49
9   com.apple.AE                    0x00007fff8722b6df AEEventImpl::initializeData() + 89
10  com.apple.AE                    0x00007fff8722b5c4 AEEventImpl::AEEventImpl(unsigned int, unsigned int, AEDesc const*, short, int) + 76
11  com.apple.AE                    0x00007fff8722f33e AECreateAppleEvent + 88
12  osascript                       0x0000000100001a42 0x100000000 + 6722
13  osascript                       0x0000000100000fa0 0x100000000 + 4000

Thread 1:  Dispatch queue: com.apple.libdispatch-manager
0   libSystem.B.dylib               0x00007fff86fa116a kevent + 10
1   libSystem.B.dylib               0x00007fff86fa303d _dispatch_mgr_invoke + 154
2   libSystem.B.dylib               0x00007fff86fa2d14 _dispatch_queue_invoke + 185
3   libSystem.B.dylib               0x00007fff86fa283e _dispatch_worker_thread2 + 252
4   libSystem.B.dylib               0x00007fff86fa2168 _pthread_wqthread + 353
5   libSystem.B.dylib               0x00007fff86fa2005 start_wqthread + 13

Thread 2:
0   libSystem.B.dylib               0x00007fff86fa1f8a __workq_kernreturn + 10
1   libSystem.B.dylib               0x00007fff86fa239c _pthread_wqthread + 917
2   libSystem.B.dylib               0x00007fff86fa2005 start_wqthread + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00000000000001f5  rcx: 0x00007fff5fbfb378  rdx: 0x0000000000000000
  rdi: 0x0000000000006134  rsi: 0x0000000000000006  rbp: 0x00007fff5fbfb390  rsp: 0x00007fff5fbfb378
   r8: 0x000000010011d740   r9: 0x00000001001fc0a4  r10: 0x00007fff86fd2656  r11: 0x0000000000000202
  r12: 0x00007fff5fbfb3c0  r13: 0x00007fff703ce328  r14: 0x00007fff82faeb5a  r15: 0x00007fff70c465c0
  rip: 0x00007fff86fd6616  rfl: 0x0000000000000202  cr2: 0x00000001000f8000

Binary Images:
       0x100000000 -        0x100002ff7 +osascript ??? (???) <1B4A05C4-8772-DCFD-444F-31FEE356E299> /usr/bin/osascript
       0x1000f1000 -        0x1000f1fff  com.apple.applescript.component 2.1.2 (2.1.2) <C621AB4A-9C10-7F1D-6B4E-0B15373D5C59> /System/Library/Components/AppleScript.component/Contents/MacOS/AppleScript
       0x100419000 -        0x1004adfe7  com.apple.applescript 2.1.2 (2.1.2) <E9C125A4-8743-6BF8-5A05-BE85778D4158> /System/Library/PrivateFrameworks/AppleScript.framework/Versions/A/AppleScript
    0x7fff5fc00000 -     0x7fff5fc3bdef  dyld 132.1 (???) <486E6C61-1197-CC7C-2197-82CE505102D7> /usr/lib/dyld
    0x7fff8011d000 -     0x7fff8011efff  liblangid.dylib ??? (???) <EA4D1607-2BD5-2EE2-2A3B-632EEE5A444D> /usr/lib/liblangid.dylib
    0x7fff8016d000 -     0x7fff8046bfe7  com.apple.HIToolbox 1.6.4 (???) <263AD497-F4CC-9610-E7D3-B95CF6F02030> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
    0x7fff80472000 -     0x7fff804befff  libauto.dylib ??? (???) <F7221B46-DC4F-3153-CE61-7F52C8C293CF> /usr/lib/libauto.dylib
    0x7fff804bf000 -     0x7fff80574fe7  com.apple.ink.framework 1.3.3 (107) <8C36373C-5473-3A6A-4972-BC29D504250F> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
    0x7fff8071a000 -     0x7fff80784fe7  libvMisc.dylib 268.0.1 (compatibility 1.0.0) <AF0EA96D-000F-8C12-B952-CB7E00566E08> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x7fff80791000 -     0x7fff80794ff7  com.apple.securityhi 4.0 (36638) <87868A3E-9341-1078-F00C-5E5972F01A4A> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
    0x7fff80795000 -     0x7fff808aefef  libGLProgrammability.dylib ??? (???) <4F2DC233-7DD2-1204-CAA5-3E6524F0AB75> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
    0x7fff808b0000 -     0x7fff8092dfef  libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
    0x7fff80949000 -     0x7fff80949ff7  com.apple.ApplicationServices 38 (38) <10A0B9E9-4988-03D4-FC56-DDE231A02C63> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
    0x7fff80a2b000 -     0x7fff80ba2fe7  com.apple.CoreFoundation 6.6.4 (550.42) <770C572A-CF70-168F-F43C-242B9114FCB5> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff80ba3000 -     0x7fff813adfe7  libBLAS.dylib 219.0.0 (compatibility 1.0.0) <FC941ECB-71D0-FAE3-DCBF-C5A619E594B8> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x7fff813ae000 -     0x7fff813b4ff7  com.apple.DiskArbitration 2.3 (2.3) <857F6E43-1EF4-7D53-351B-10DE0A8F992A> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x7fff813e6000 -     0x7fff813e9ff7  libCoreVMClient.dylib ??? (???) <609598E6-195D-E5D4-3B92-AE8D9768829C> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
    0x7fff813ea000 -     0x7fff813fefff  libGL.dylib ??? (???) <1EB1BD0F-C17F-55DF-B8B4-8E9CF99359D4> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
    0x7fff81480000 -     0x7fff814b9fef  libcups.2.dylib 2.8.0 (compatibility 2.0.0) <561D0DCB-47AD-A12C-9066-70E4CBAD331C> /usr/lib/libcups.2.dylib
    0x7fff816aa000 -     0x7fff816f4ff7  com.apple.Metadata 10.6.3 (507.15) <5170FCE0-ED6C-2E3E-AB28-1DDE3F628FC5> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x7fff8185b000 -     0x7fff81876ff7  com.apple.openscripting 1.3.1 (???) <9D50701D-54AC-405B-CC65-026FCB28258B> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
    0x7fff818b9000 -     0x7fff81901ff7  libvDSP.dylib 268.0.1 (compatibility 1.0.0) <98FC4457-F405-0262-00F7-56119CA107B6> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x7fff81940000 -     0x7fff8194ffff  com.apple.NetFS 3.2.1 (3.2.1) <E5D33870-27D2-E50B-9B35-16AA50369733> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
    0x7fff81950000 -     0x7fff81a67fef  libxml2.2.dylib 10.3.0 (compatibility 10.0.0) <B2FB9DA8-6EC9-FFBC-C919-C022B9CBEB73> /usr/lib/libxml2.2.dylib
    0x7fff81a98000 -     0x7fff81b51fff  libsqlite3.dylib 9.6.0 (compatibility 9.0.0) <2C5ED312-E646-9ADE-73A9-6199A2A43150> /usr/lib/libsqlite3.dylib
    0x7fff81b52000 -     0x7fff81c07fe7  com.apple.ColorSync 4.6.3 (4.6.3) <5A7360A8-D495-1E8D-C4B4-A363AF989ADE> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
    0x7fff81c08000 -     0x7fff81c33ff7  libxslt.1.dylib 3.24.0 (compatibility 3.0.0) <87A0B228-B24A-C426-C3FB-B40D7258DD49> /usr/lib/libxslt.1.dylib
    0x7fff81e28000 -     0x7fff81e59fff  libGLImage.dylib ??? (???) <1A8E58CF-FA2F-14F7-A097-D34EEA8A7D03> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
    0x7fff81e5a000 -     0x7fff81e6cfe7  libsasl2.2.dylib 3.15.0 (compatibility 3.0.0) <76B83C8D-8EFE-4467-0F75-275648AFED97> /usr/lib/libsasl2.2.dylib
    0x7fff81e6d000 -     0x7fff81f2aff7  com.apple.CoreServices.OSServices 357 (357) <7B22626F-D544-1955-CC53-240F4CACEB4A> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x7fff81f2b000 -     0x7fff81f30ff7  com.apple.CommonPanels 1.2.4 (91) <4D84803B-BD06-D80E-15AE-EFBE43F93605> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
    0x7fff81f47000 -     0x7fff81f6ffff  com.apple.DictionaryServices 1.1.2 (1.1.2) <E9269069-93FA-2B71-F9BA-FDDD23C4A65E> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    0x7fff81fce000 -     0x7fff81fceff7  com.apple.Carbon 150 (152) <191B4F4B-8D06-796B-CA0C-782F06DD7BC7> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
    0x7fff81fe1000 -     0x7fff81fe4fff  com.apple.help 1.3.1 (41) <54B79BA2-B71B-268E-8752-5C8EE00E49E4> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
    0x7fff81fe5000 -     0x7fff81ff9ff7  com.apple.speech.synthesis.framework 3.10.35 (3.10.35) <621B7415-A0B9-07A7-F313-36BEEDD7B132> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
    0x7fff81ffa000 -     0x7fff8201dfff  com.apple.opencl 12.3 (12.3) <D30A45FC-4520-45AF-3CA5-092313DB5D54> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
    0x7fff8201e000 -     0x7fff82024ff7  com.apple.CommerceCore 1.0 (6) <E8A1144C-5666-9840-4729-256FE69CDBDB> /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/CommerceCore.framework/Versions/A/CommerceCore
    0x7fff82073000 -     0x7fff82088ff7  com.apple.LangAnalysis 1.6.6 (1.6.6) <1AE1FE8F-2204-4410-C94E-0E93B003BEDA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
    0x7fff82107000 -     0x7fff82148fff  com.apple.SystemConfiguration 1.10.5 (1.10.2) <FB39F09C-57BB-D8CC-348D-93E00C602F7D> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x7fff82149000 -     0x7fff823cffff  com.apple.security 6.1.1 (37594) <1B4E1ABD-1BB3-DA49-F574-0EEB23E73C6A> /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x7fff825d4000 -     0x7fff825d5ff7  com.apple.audio.units.AudioUnit 1.6.5 (1.6.5) <14F14B5E-9287-BC36-0C3F-6592E6696CD4> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
    0x7fff825d6000 -     0x7fff825e5fff  com.apple.opengl 1.6.12 (1.6.12) <DE3F0528-7759-CDFD-A2CF-C51D3C9C8B39> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
    0x7fff825e6000 -     0x7fff8269cfff  libobjc.A.dylib 227.0.0 (compatibility 1.0.0) <99CB3A0F-64CF-1D16-70CD-8AED2EF06C30> /usr/lib/libobjc.A.dylib
    0x7fff8269d000 -     0x7fff826fdfe7  com.apple.framework.IOKit 2.0 (???) <D107CB8A-5182-3AC4-35D0-07068A695C05> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x7fff8287e000 -     0x7fff828a4fe7  libJPEG.dylib ??? (???) <DFA5DAC2-D1C6-D5ED-F95D-AC185E98B6E7> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
    0x7fff828eb000 -     0x7fff82c1ffff  com.apple.CoreServices.CarbonCore 861.23 (861.23) <96465459-6536-3FD7-7504-B59D0390EEC5> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x7fff82ca9000 -     0x7fff82d28fe7  com.apple.audio.CoreAudio 3.2.6 (3.2.6) <6D8AD3F7-409D-512C-C5BE-66C64D1B8F3E> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
    0x7fff82d29000 -     0x7fff82dd8fff  edu.mit.Kerberos 6.5.10 (6.5.10) <6A159CD8-5C02-4528-C36F-6AFBFD61576B> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
    0x7fff82fa2000 -     0x7fff83042fff  com.apple.LaunchServices 362.2 (362.2) <A8EDC37C-1D40-5ED0-49BE-90EF110A6B3A> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x7fff83055000 -     0x7fff83213fff  libicucore.A.dylib 40.0.0 (compatibility 1.0.0) <781E7B63-2AD0-E9BA-927C-4521DB616D02> /usr/lib/libicucore.A.dylib
    0x7fff83214000 -     0x7fff833cbfef  com.apple.ImageIO.framework 3.0.4 (3.0.4) <EE9DFBD6-6354-7C5A-F4C7-5FF782A7D992> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
    0x7fff833cc000 -     0x7fff833cdff7  libScreenReader.dylib ??? (???) <D98F32A6-4729-8040-AE06-76D2F4CF9BBB> /usr/lib/libScreenReader.dylib
    0x7fff833ce000 -     0x7fff833ceff7  com.apple.CoreServices 44 (44) <DC7400FB-851E-7B8A-5BF6-6F50094302FB> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x7fff8340c000 -     0x7fff8340dff7  com.apple.TrustEvaluationAgent 1.1 (1) <5952A9FA-BC2B-16EF-91A7-43902A5C07B6> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff8340e000 -     0x7fff83427fff  com.apple.CFOpenDirectory 10.6 (10.6) <CCF79716-7CC6-2520-C6EB-A4F56AD0A207> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
    0x7fff83428000 -     0x7fff834a6fff  com.apple.CoreText 3.5.0 (???) <4D5C7932-293B-17FF-7309-B580BB1953EA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText
    0x7fff83730000 -     0x7fff83782ff7  com.apple.HIServices 1.8.2 (???) <7C91D07D-FA20-0882-632F-0CAE4FAC2B79> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
    0x7fff8381c000 -     0x7fff83942fff  com.apple.audio.toolbox.AudioToolbox 1.6.5 (1.6.5) <B51023BB-A5C9-3C65-268B-6B86B901BB2C> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
    0x7fff83943000 -     0x7fff83992ff7  com.apple.DirectoryService.PasswordServerFramework 6.0 (6.0) <FE549581-6A40-BD28-24A4-68FA0B616780> /System/Library/PrivateFrameworks/PasswordServer.framework/Versions/A/PasswordServer
    0x7fff83993000 -     0x7fff839a9fef  libbsm.0.dylib ??? (???) <42D3023A-A1F7-4121-6417-FCC6B51B3E90> /usr/lib/libbsm.0.dylib
    0x7fff839f7000 -     0x7fff83ac9fe7  com.apple.CFNetwork 454.11.5 (454.11.5) <5D68598D-C138-C8B6-B6AC-B1F48B01E021> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x7fff83bb1000 -     0x7fff83bb1ff7  com.apple.Accelerate 1.6 (Accelerate 1.6) <15DF8B4A-96B2-CB4E-368D-DEC7DF6B62BB> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x7fff83bb2000 -     0x7fff83c4cfff  com.apple.ApplicationServices.ATS 4.4 (???) <395849EE-244A-7323-6CBA-E71E3B722984> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
    0x7fff83c4d000 -     0x7fff83c63fff  com.apple.ImageCapture 6.0.1 (6.0.1) <09ABF2E9-D110-71A9-4A6F-8A61B683E936> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
    0x7fff84091000 -     0x7fff841b2fe7  libcrypto.0.9.8.dylib 0.9.8 (compatibility 0.9.8) <48AEAFE1-21F4-B3C8-4199-35AD5E8D0613> /usr/lib/libcrypto.0.9.8.dylib
    0x7fff841bb000 -     0x7fff841d1fe7  com.apple.MultitouchSupport.framework 207.10 (207.10) <458F0259-6EDC-16BA-E6AA-1CEED002D188> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
    0x7fff841e4000 -     0x7fff84269ff7  com.apple.print.framework.PrintCore 6.3 (312.7) <CDFE82DD-D811-A091-179F-6E76069B432D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
    0x7fff8426a000 -     0x7fff84607fe7  com.apple.QuartzCore 1.6.3 (227.34) <C4AABD56-8C93-BAD0-4B27-7E9A2F0EAEE4> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
    0x7fff8463e000 -     0x7fff8463eff7  com.apple.vecLib 3.6 (vecLib 3.6) <96FB6BAD-5568-C4E0-6FA7-02791A58B584> /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff84927000 -     0x7fff84932ff7  com.apple.speech.recognition.framework 3.11.1 (3.11.1) <3D65E89B-FFC6-4AAF-D5CC-104F967C8131> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
    0x7fff84d5e000 -     0x7fff84d63fff  libGIF.dylib ??? (???) <A7BF2D68-F489-720C-E5A9-DC2B24DC5A21> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
    0x7fff84da8000 -     0x7fff851ebfef  libLAPACK.dylib 219.0.0 (compatibility 1.0.0) <0CC61C98-FF51-67B3-F3D8-C5E430C201A9> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x7fff85efd000 -     0x7fff85f1dff7  com.apple.DirectoryService.Framework 3.6 (621.9) <E7AFAAFA-8221-585B-85D0-171ADC490825> /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService
    0x7fff85f1e000 -     0x7fff85f23fff  libGFXShared.dylib ??? (???) <991F8197-FD06-2AF1-F99B-E448ED4FB2AC> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
    0x7fff85f24000 -     0x7fff85ffeff7  com.apple.vImage 4.0 (4.0) <354F34BF-B221-A3C9-2CA7-9BE5E14AD5AD> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x7fff8603a000 -     0x7fff8673706f  com.apple.CoreGraphics 1.545.0 (???) <356D59D6-1DD1-8BFF-F9B3-1CE51D2F1EC7> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
    0x7fff86738000 -     0x7fff86738ff7  com.apple.Accelerate.vecLib 3.6 (vecLib 3.6) <4CCE5D69-F1B3-8FD3-1483-E0271DB2CCF3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff8687c000 -     0x7fff868c3ff7  com.apple.coreui 2 (114) <923E33CC-83FC-7D35-5603-FB8F348EE34B> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
    0x7fff86ab9000 -     0x7fff86b45fef  SecurityFoundation ??? (???) <F43FDB02-CAA5-F8FF-C8D7-6665E7403ECE> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
    0x7fff86b46000 -     0x7fff86b63ff7  libPng.dylib ??? (???) <667C3883-32A5-CCCC-8624-972B5DFD8EA4> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
    0x7fff86b89000 -     0x7fff86baafff  libresolv.9.dylib 41.0.0 (compatibility 1.0.0) <9F322F47-0584-CB7D-5B73-9EBD670851CD> /usr/lib/libresolv.9.dylib
    0x7fff86bab000 -     0x7fff86e2eff7  com.apple.Foundation 6.6.4 (751.42) <AF1E3050-3503-8714-8274-EA6BD6BE8A22> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x7fff86e2f000 -     0x7fff86f6dfff  com.apple.CoreData 102.1 (251) <9DFE798D-AA52-6A9A-924A-DA73CB94D81A> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    0x7fff86f87000 -     0x7fff87148fff  libSystem.B.dylib 125.2.1 (compatibility 1.0.0) <F00A8B2F-84A0-0868-1047-3A13F9114864> /usr/lib/libSystem.B.dylib
    0x7fff8718b000 -     0x7fff8718dfff  libRadiance.dylib ??? (???) <6C974488-62D2-71BA-A45E-C764A0AF7354> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
    0x7fff871de000 -     0x7fff8721ffef  com.apple.QD 3.36 (???) <5DC41E81-32C9-65B2-5528-B33E934D5BB4> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
    0x7fff87229000 -     0x7fff87264fff  com.apple.AE 496.4 (496.4) <55AAD5CA-7160-7899-1C68-562ED8160DF7> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x7fff8728f000 -     0x7fff87293ff7  libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
    0x7fff873bd000 -     0x7fff873ceff7  libz.1.dylib 1.2.3 (compatibility 1.0.0) <97019C74-161A-3488-41EC-A6CA8738418C> /usr/lib/libz.1.dylib
    0x7fff873cf000 -     0x7fff87418fef  libGLU.dylib ??? (???) <CCE779A9-2467-A5AA-A558-691E43A1105F> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
    0x7fff87419000 -     0x7fff8746eff7  com.apple.framework.familycontrols 2.0.2 (2020) <A3CFF697-B9DB-A7E5-3B39-9DA9B34F0595> /System/Library/PrivateFrameworks/FamilyControls.framework/Versions/A/FamilyControls
    0x7fff8746f000 -     0x7fff874fffff  com.apple.SearchKit 1.3.0 (1.3.0) <4175DC31-1506-228A-08FD-C704AC9DF642> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x7fff87528000 -     0x7fff875e9fe7  libFontParser.dylib ??? (???) <8B12D37E-3A95-5A73-509C-3AA991E0C546> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
    0x7fff8766e000 -     0x7fff876bdfef  libTIFF.dylib ??? (???) <176B52ED-4F6C-D0C2-EABC-C032BFC3DFAA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
    0x7fff876be000 -     0x7fff876c4ff7  IOSurface ??? (???) <EAD87C9F-BADC-7116-4ADD-0B0679459D24> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
    0x7fff87dce000 -     0x7fff87dd5fff  com.apple.OpenDirectory 10.6 (10.6) <4200CFB0-DBA1-62B8-7C7C-91446D89551F> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
    0x7fff87fba000 -     0x7fff8809ffef  com.apple.DesktopServices 1.5.9 (1.5.9) <27890B2C-0CD2-7C27-9D0C-D5952C5E8438> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
    0x7fff884b9000 -     0x7fff884c7ff7  libkxld.dylib ??? (???) <27713C39-0E51-8F5A-877B-C5539C96A520> /usr/lib/system/libkxld.dylib
    0x7fff884c8000 -     0x7fff88ebefff  com.apple.AppKit 6.6.7 (1038.35) <9F4DF818-9DB9-98DA-490C-EF29EA757A97> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
    0x7fff890fb000 -     0x7fff89120ff7  com.apple.CoreVideo 1.6.2 (45.6) <E138C8E7-3CB6-55A9-0A2C-B73FE63EA288> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
    0x7fff89121000 -     0x7fff89123fff  com.apple.print.framework.Print 6.1 (237.1) <CA8564FB-B366-7413-B12E-9892DA3C6157> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
    0x7fffffe00000 -     0x7fffffe01fff  libSystem.B.dylib ??? (???) <F00A8B2F-84A0-0868-1047-3A13F9114864> /usr/lib/libSystem.B.dylib

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟沫凡尘 2024-10-21 02:58:16

我通过测试发现了我们的问题。我想问你一个问题,你是如何开始剧本的?是从登录机器并在 Mac OSX 桌面屏幕中启动终端开始的吗?或者您是否通过 ssh 进入 Mac 并从那里启动它。

在尝试使用窗口管理器(firefox)的守护进程上,如果我们通过登录用户的 Terminal.app 启动它。效果会很好。如果我们通过 ssh 启动脚本(当您使用 Capistrano 启动脚本时会发生这种情况),它将正常工作,直到 ssh 会话停止。在控制台中,您可以看到日志:

2/7/11 8:32:13 PM    com.apple.SecurityServer[22]    Session 0x22058d0 destroyed
2/7/11 8:32:13 PM    com.apple.SecurityServer[22]    Session 0x22058d0 dead
2/7/11 8:32:13 PM    com.apple.SecurityServer[22]    Killing auth hosts

这发生在我们终止 SSH 会话之后。终止后,我们会得到像您一样的错误:

abort() called
LaunchServices: GetOurLSSessionIDInit() returned err #1, 
    securitySessionID == 0x0, vers=10600000 uid=501 euid=501

我们现在不再通过 ssh 启动脚本,而是使用一个 LaunchAgent,它将基于 WatchPaths 和 ~/jobs/ 目录启动脚本。效果很好,我们仍然可以使用 capistrano 重新启动服务器。

我会查看您的日志,看看 SecurityServer 是否在脚本失败时正在销毁会话。如果是这样,那么也许您可以找出导致超时的原因。

I have found out via testing about our issues. One question I had for you, is how are you starting the script? Is it started from logging on the machine and starting a terminal in the Mac OSX desktop screen? Or are you ssh'ing into the Mac and starting it from there.

On our daemon that was trying to use the Window Manager (firefox), if we started it via the Terminal.app from the logged in user. It would work fine. If we ssh'd in to start the script (which happens when you use Capistrano to start it) it would work fine until that ssh session was stopped. In the Console you can see the logs:

2/7/11 8:32:13 PM    com.apple.SecurityServer[22]    Session 0x22058d0 destroyed
2/7/11 8:32:13 PM    com.apple.SecurityServer[22]    Session 0x22058d0 dead
2/7/11 8:32:13 PM    com.apple.SecurityServer[22]    Killing auth hosts

This happens after we terminate the SSH session. After it terminates, we would get the errors like you did:

abort() called
LaunchServices: GetOurLSSessionIDInit() returned err #1, 
    securitySessionID == 0x0, vers=10600000 uid=501 euid=501

Instead of starting the script via ssh, we now have a LaunchAgent which will start the script based on WatchPaths with a ~/jobs/ directory. It works out well, and we can still restart the server with capistrano.

I would look in your logs to see if the SecurityServer is destroying a session right about the time the script fails. If so, then maybe you can figure out what is causing the timeout.

淡紫姑娘! 2024-10-21 02:58:16

我相信 AppleScript 需要一个窗口管理器才能运行。您是否已登录该计算机?Applescript 是否会以该用户身份被触发?

AppleScript I believe needs a window manager to run. Are you logged in on that machine, and does the Applescript get triggered as that user?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文