小编Pha*_*ani的帖子

Ruby方法的测量和基准时间

如何在Ruby中测量方法和该方法中各个语句所花费的时间.如果您看到以下方法,我想测量方法所花费的总时间以及数据库访问和redis访问所用的时间.我不想在每个声明之前写Benchmark.measure.ruby解释器是否为我们提供了任何钩子?

def foo
# code to access database
# code to access redis. 
end
Run Code Online (Sandbox Code Playgroud)

ruby time benchmarking interpreter ruby-on-rails

76
推荐指数
5
解决办法
5万
查看次数

在节点进程被终止时杀死所有child_process

如何确保在父进程被终止时所有child_process被杀死.我有类似下面的东西.

即使节点进程被终止,我也看到FFMPEG继续运行并且生成了out.avi.如何在节点进程退出后停止运行FFMPEG.

var args = "ffmpeg -i in.avi out.avi"
child_process.exec(args , function(err, stdout,stderr){});

child_process.exec(args , function(err, stdout,stderr){});
Run Code Online (Sandbox Code Playgroud)

cluster-computing child-process node.js

22
推荐指数
1
解决办法
2万
查看次数

在docker容器中使用akka应用程序的问题

我们有一个以非集群模式在生产中运行的akka​​应用程序(不是akka集群).我们正在尝试将此应用程序停靠,并遇到问题.我们正在使用docker主机网络,并且由于各种其他原因,我们尚未准备好使用其他类型的网络.

应用程序绑定到端口9080上的0.0.0.0接口,并对其自身进行简单的http运行状况检查.此运行状况检查失败,因为我们看到连接重置错误.我们只在docker容器内看到这个.

在启动时,应用程序绑定到0:0:0:0:0:0:0:0:9080.2018-04-13T08:29:54.921-0700 [INFO] - 绑定到/ 0:0:0:0:0:0:0:0:9080

akka日志:

2018-04-13T08:34:25.311-0700 [DEBUG] akka.io.TcpListener            [15:34:25.311UTC] - New connection accepted
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.SelectionHandler       [15:34:25.312UTC] - now supervising Actor[akka://appname/system/IO-TCP/selectors/$d/12#394551476]
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.312UTC] - started (akka.io.TcpIncomingConnection@1dafecc7)
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.312UTC] - now watched by Actor[akka://appname/system/IO-TCP/selectors/$d#992175932]
2018-04-13T08:34:25.312-0700 [DEBUG] akka.io.TcpIncomingConnection  [15:34:25.312UTC] - now watched by Actor[akka://appname/user/IO-HTTP/listener-0/88#-1187840999]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.SelectionHandler       [15:34:25.313UTC] - now supervising Actor[akka://appname/system/IO-TCP/selectors/$h/11#789402148]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - started (akka.io.TcpOutgoingConnection@62c77639)
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - now watched by Actor[akka://appname/system/IO-TCP/selectors/$h#227381172]
2018-04-13T08:34:25.313-0700 [DEBUG] akka.io.TcpOutgoingConnection  [15:34:25.313UTC] - Attempting connection …
Run Code Online (Sandbox Code Playgroud)

akka spray docker

8
推荐指数
1
解决办法
473
查看次数

如何防止Rails从Action查看生产中的日志记录

在rails 3.2.0中,是否可以在生产环境中关闭用于在ActionView :: LogSubscriber中呈现视图的rails日志记录.

目前只有我发现supress的方法是对它进行修补并通过以下方式增加日志级别进行调试.有没有更好的方法来执行此操作或任何配置?

 module ActionView
    class LogSubscriber
       def render_template(event)
            message = "Rendered #{from_rails_root(event.payload[:identifier])}"
            message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
            message << (" (%.1fms)" % event.duration)
            debug(message)
       end
          alias :render_partial :render_template
          alias :render_collection :render_template
     end
  end
Run Code Online (Sandbox Code Playgroud)

actionview ruby-on-rails-3.2

4
推荐指数
1
解决办法
1136
查看次数

ruby中的实例变量

 class Sample
   attr_accessor :x,:y

   def initialize 
     @x = "x"
     y = "y"     
   end
 end     

 Sample.new.instance_variables  => [:@x] 

class Sample
  attr_accessor :x,:y

  def initialize 
     @x = "x"
     self.y = "y"     
  end
end  

Sample.new.instance_variables => [:@x, :@y] 
Run Code Online (Sandbox Code Playgroud)

任何人都可以让我知道这里发生了什么.为什么y第二次是instance_variable?

ruby

1
推荐指数
1
解决办法
88
查看次数