RailsCasts Pro episodes are now free!
Learn more or hide this
Resources
rake middleware rails s -e production -d ab -n 100 -r http://localhost:3000/processes/old_list ab -n 100 -r http://localhost:3000/processes/list
class ProcessesList def initialize(app) @app = app end def call(env) if env["PATH_INFO"] == "/processes/list" list = `ps -axcr -o 'pid,pcpu,pmem,time,comm'` [200, {"Content-Type" => "text/plain"}, [list]] else @app.call(env) end end end
config.middleware.insert_before 0, "ProcessesList"