【发布时间】:2012-03-31 17:39:40
【问题描述】:
我在 Lion (10.7.3) 上使用 launchctl 在系统启动时的 2 个不同端口上加载 2 个 SickBeard(python 脚本)实例。
我在 ~/Library/LaunchAgents 中的 plist 如下。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sickbeard.sickbeard</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Frameworks/Python.framework/Versions/2.7/bin/python</string>
<string>/Users/james/Applications/Sick-Beard/SickBeard.py</string>
<string>-q</string>
<string>-d</string>
</array>
<key>StandardOutPath</key>
<string>/var/log/sickbeard/sickbeard.log</string>
<key>StandardErrorPath</key>
<string>/var/log/sickbeard/sickbeard_error.log</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
我已确认 python 从该位置启动,并且 SB 也是正确的......确实,两个 Python 实例在启动时都正确加载 - 请参阅下面的“顶部”。
Processes: 94 total, 3 running, 91 sleeping, 450 threads 20:22:54
Load Avg: 6.19, 6.24, 6.39 CPU usage: 94.33% user, 5.66% sys, 0.0% idle
SharedLibs: 82M resident, 0B data, 11M linkedit.
MemRegions: 10801 total, 1189M resident, 40M private, 212M shared.
PhysMem: 927M wired, 1622M active, 3207M inactive, 5757M used, 2435M free.
VM: 222G vsize, 1344M framework vsize, 110371(0) pageins, 89(0) pageouts.
Networks: packets: 1118035/1205M in, 2206764/2119M out. Disks: 323025/15G read, 52125/11G written.
PID COMMAND %CPU TIME #TH #WQ #POR #MRE RPRVT RSHRD RSIZE VPRVT VSIZE PGRP PPID STATE UID
1312 top 5.8 00:00.55 1/1 0 28 38 1044K 216K 1760K 19M 2379M 1312 733 running 0
1246 taskgated 0.0 00:00.01 1 0 30 40 496K 320K 1860K 28M 2388M 1246 1 sleeping 0
1242 mdworker 0.0 00:00.10 3 1 54 70 1540K 13M 5748K 31M 2418M 1242 280 sleeping 89
1241 mdworker 0.0 00:00.98 3 1 50 78 6952K 6252K 12M 28M 2416M 1241 217 sleeping 501
733 bash 0.0 00:00.01 1 0 21 24 288K 760K 1056K 17M 2378M 733 732 sleeping 501
732 sshd 0.0 00:00.02 1 0 13 82 256K 1444K 844K 9740K 2394M 717 717 sleeping 501
717 sshd 0.0 00:00.07 2 1 35 76 488K 1444K 2916K 8884K 2393M 717 1 sleeping 0
703 check_afp 0.0 00:00.02 4 1 44 42 480K 220K 1160K 29M 2389M 703 1 sleeping 0
516 AppleSpell 0.0 00:00.14 2 1 47 52 1172K 5544K 4680K 30M 2412M 516 217 sleeping 501
482 filecoordina 0.0 00:00.02 2 2 38 45 540K 248K 1824K 30M 2390M 482 1 sleeping 0
469 HandBrakeCLI 182.9 01:43:54 22/6 1 79 477 517M 268K 520M 707M 3092M 313 455 running 501
455 bash 0.0 00:00.02 1 0 17 23 216K 756K 888K 9648K 2378M 313 313 sleeping 501
339- dbfseventsd 0.0 00:01.67 1 0 9 24 20K 324K 176K 20K 583M 314 338 sleeping 501
338- dbfseventsd 0.0 00:02.03 1 0 9 24 4180K 320K 4372K 12M 591M 314 336 sleeping 0
336- dbfseventsd 0.0 00:00.43 1 0 16 23 36K 308K 376K 5188K 583M 314 314 sleeping 0
331 Python 0.1 00:16.93 20 0 37 305 63M 2552K 60M 164M 2528M 330 1 sleeping 501
329 Python 0.2 00:20.41 20 0 47 323 55M 2552K 66M 166M 2530M 328 1 sleeping 501
314- Dropbox 0.0 00:52.95 17 1 116 483 70M 22M 86M 99M 743M 314 217 sleeping 501
313 SABnzbd 7.1 03:41.14 23 1 113 589 170M 22M 203M 219M 2640M 313 217 sleeping 501
312 Alfred 0.0 00:00.38 2 1 110 118 6004K 31M 16M 32M 2472M 312 217 sleeping 501
311 Growl 0.0 00:00.69 5 1 149 129 8636K 21M 18M 165M 3480M 311 217 sleeping 501
我遇到的问题是,虽然“launchctl start com.sickbeard.sickbeard”可以启动进程,但“launchctl stop com.sickbeard.sickbeard”并没有阻止它。 如果我尝试从 GUI 启动自动更新,则会失败,提示我查看日志。 日志在适当的时间戳包括以下内容。
Mar-24 20:15:25 DEBUG CP Server Thread-4 :: After checking, cur_commit = a392367b16b197ca59a5017f5ecfb37ade2f26f4, newest_commit = a392367b16b197ca59a5017f5ecfb37ade2f26f4, num_commits_behind = 0
Mar-24 20:15:25 DEBUG CP Server Thread-4 :: newest: a392367b16b197ca59a5017f5ecfb37ade2f26f4 and current: a392367b16b197ca59a5017f5ecfb37ade2f26f4 and num_commits: 0
AA
Mar-24 20:15:22 DEBUG CP Server Thread-4 :: Git output: a392367b16b197ca59a5017f5ecfb37ade2f26f4
AA
Mar-24 20:15:22 DEBUG CP Server Thread-4 :: git output: a392367b16b197ca59a5017f5ecfb37ade2f26f4
Mar-24 20:15:22 DEBUG CP Server Thread-4 :: Executing "/usr/local/git/bin/git" rev-parse HEAD with your shell in /Users/james/Applications/Sick-Beard
Git 确实在 /usr/local/bin/git 中。 奇怪的是,我不记得更改任何可能导致此问题的东西 - 以前有人遇到过这个问题吗? 我已经浏览了这些论坛上的所有 launchctl 主题,并尝试了对 plist 等进行的所有小的个性化更改,但都没有真正起到任何作用。
在我未经训练的眼睛看来,python 正在从父 SickBeard 进程中妖魔化自己,因此它超出了它的管辖范围,然后在启动请求时停止。
您的帮助和想法将不胜感激! 如果有任何我错过的有用信息,请告诉我。
:)
【问题讨论】:
标签: python macos osx-lion launchd