草庐IT

ZendX_Console_Process_Unix

全部标签

Ruby - 创建 gem : reload console with updated gem content

根据这个article,我们可以通过将这些行添加到我们的rakefile来测试我们的gem代码:​​task:consoledorequire'irb'require'irb/completion'require'my_gem'#Youknowwhattodo.ARGV.clearIRB.startend它工作得很好,只是每当对gem进行更改时,我都需要退出并重新运行rakeconsole以更新代码。作为创建/调试工具确实不方便...有没有一种方法可以编写一个自定义方法来充当Rails中很棒的reload!方法?bash脚本不会工作,因为第一个命令在Ruby控制台中,我宁愿有一个100

ruby - Windows 上有哪些 Process.kill 信号可用?

来自Process.kill的文档:Sendsthegivensignaltothespecifiedprocessid(s)ifpidispositive.IfpidiszerosignalissenttoallprocesseswhosegroupIDisequaltothegroupIDoftheprocess.signalmaybeanintegersignalnumberoraPOSIXsignalname(eitherwithorwithoutaSIGprefix).Ifsignalisnegative(orstartswithaminussign),killsproces

ruby - 在 Ruby 中使用 Unix 进程控制方法

RyanTomayko用thispost引发了一场激烈的Storm关于使用Unix进程控制命令。Weshouldbedoingmoreofthis.Alotmoreofthis.I'mtalkingaboutfork(2),execve(2),pipe(2),socketpair(2),select(2),kill(2),sigaction(2),andsoonandsoforth.Theseareourfriends.Theywantsobadlyjusttohelpus.我有一些代码(DataMapper的delayed_job克隆,我认为它适合这个,但我不清楚如何利用列出的命令。

ruby-on-rails - rails console - 运行一段代码

我了解如何在Rails控制台中运行一段简单的代码。说Swimming::Student.create(:name="Jerry")我如何运行一大段代码(很多行)Swimming::Student.all.each{|student|student.attended=flasestudent.save} 最佳答案 如您所料,只需按回车键:$railscLoadingdevelopmentenvironment(Rails3.2.13)2.0.0p0:001>Student.all.eachdo|student|#enter2.0.0p

ruby-on-rails - rails 2 : test 'link_to' and other view helpers from the rails console?

在Rails2中,我经常使用控制台,并且想知道使用它测试View助手(例如“link_to”或“url_for”)的最佳方法是什么。执行此操作的最佳方法是什么? 最佳答案 您可以将您的includeActionView::Helpers::UrlHelper添加到~/.irbrc以在您启动控制台时自动加载它。 关于ruby-on-rails-rails2:test'link_to'andotherviewhelpersfromtherailsconsole?,我们在StackOverfl

ruby - 在 Ruby 中从 Unix 套接字读取/写入

我正在尝试通过Ruby中的UNIX套接字进行连接、读取和写入。它是haproxy使用的统计套接字。我的代码如下:require'socket'socket=UNIXSocket.new("/tmp/haproxy.stats.socket")#Firstattempt:workssocket.puts("showstat")while(line=socket.gets)doputslineend#Secondattemp:failssocket.puts("showstat")while(line=socket.gets)doputslineend第一次成功,第二次失败。我不确定为什么

ruby-on-rails - postgresql 数据库错误 : Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

当我运行rakedb:migrate或运行railss命令时,我得到同样的错误:Error:couldnotconnecttoserver:NosuchfileordirectoryIstheserverrunninglocallyandacceptingconnectionsonUnixdomainsocket"/var/run/postgresql/.s.PGSQL.5432"?当我尝试railss时,浏览器出现错误。这是我的database.ymldefault:&defaultadapter:postgresqlencoding:unicodepool:5development

ruby-on-rails - 抽取 Assets :precompile gets killed when there is a console session open in production

在我托管在digitalocean上的生产服务器上,如果有帮助的话,Ubuntu12.04,我有RoR4和rake10.1.1。当我部署时,我运行rakeassets:precompile,我注意到一个奇怪的问题,如果我在执行此操作时打开了一个railsconsolesession,我得到以下输出~#rakeassets:precompile~#Killed主要是很烦人,但我希望解决这个问题的原因是在雇用新开发人员时,会有部署/控制台冲突噩梦。谢谢,布莱恩 最佳答案 您的预编译进程可能被终止,因为您的内存不足。您可以通过在另一个ss

ruby - Unix 哲学在 Ruby 社区失宠了吗?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭8年前。ImprovethisquestionDavidKorn,Unix哲学的支持者,几年前在aSlashdotinterview中斥责Perl程序员用于编写单一的Perl脚本而不通过管道、重定向等使用Unix工具包。“Unix不仅仅是一个操作系统,”他说,“它是一种做事的方式,shell通过提供使它起作用的胶水。”似乎提醒同样适用于Ruby社区。Ruby具有通过popen、STDIN、STDOUT、STDERR、ARGF等与其他U

ruby-on-rails - 在 Unix 上,查找执行该程序的用户是否为 root?

我正在编写一个rake脚本,并希望检测(如果可能,使用Ruby而不是bash)执行rake脚本的用户是否具有root权限。如果它不是root那么我想终止脚本。 最佳答案 使用uid或euid在Process类:raise'Mustrunasroot'unlessProcess.uid==0 关于ruby-on-rails-在Unix上,查找执行该程序的用户是否为root?,我们在StackOverflow上找到一个类似的问题: https://stackove