mac上迅雷下载不动的解决---上海003

最近犯懒,自责下!

一个人在上海,突然又想看经典的《兄弟连》了,找了个bt种子下载,但是mac上的迅雷不知道怎么回事。下一段时间就不动了,重启迅雷后,又能高速下载。于是想自己写段代码去定时杀死重启,查下资料,就用最近在学的ruby仿照一下。

遇到个问题就是在安装proctable这个gem的时候,出现这个错误 Failed to build gem native extension. 解决方法如下

http://stackoverflow.com/questions/8389301/failed-to-build-gem-native-extension-when-installing-rails-on-my-mac

xcode里面安装一个东西。

具体代码如下:

require 'sys/proctable'
require 'time'

def restartThunder
        puts 'search process Thunder...'
        Sys::ProcTable.ps.each { |ps|
                if ps.comm == 'Thunder'
                        puts 'got Thunder and kill it...'
                        Process.kill('KILL', ps.pid)
                        puts 'Thunder was killed and restart it...'
                        system 'open -a Thunder.app'
                        puts "#{Time.now} restart over!"
                end
        }
end

t = Thread.new do
        while true do
                sleep 30*60
                restartThunder
        end

end

t.join

以上

你可能感兴趣的:(mac上迅雷下载不动的解决---上海003)