citizen428.blog()

Try to learn something about everything

A Little Pow Helper

If you are a Ruby developer on MacOS X, you probably love Pow as much as I do. While skimming the fine manual today, I noticed section 3.2, “Reading the Current Configuration”, which explains that you can query Pow’s config and status via simple HTTP requests:

Query Pow’s statusPow manual
1
curl -H host:pow localhost/status.json

Since I know I’d probably forget that sooner than later, I immediately wrapped it up in a small script, which I called pow-show and put in ~/bin:

~/bin/pow-show
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env ruby

require 'json'

unless %w(status config).include?(ARGV[0])
  puts "Usage: #{File.basename($0)} status|config"
  exit 1
end

jj JSON.parse(`curl -s -H host:pow localhost/#{ARGV[0]}.json`)

Here’s some example output:

pow-show status
1
2
3
4
5
{
  "pid": 802,
  "version": "0.3.2",
  "requestCount": 134
}
pow-show config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
  "bin": "/Users/name/Library/Application Support/Pow/Versions/0.3.2/bin/pow",
  "dstPort": 80,
  "httpPort": 20559,
  "dnsPort": 20560,
  "timeout": 900,
  "workers": 2,
  "domains": [
    "dev"
  ],
  "extDomains": [

  ],
  "hostRoot": "/Users/name/Library/Application Support/Pow/Hosts",
  "logRoot": "/Users/name/Library/Logs/Pow",
  "rvmPath": "/Users/name/.rvm/scripts/rvm"
}

Maybe that’s useful for someone else too.

Comments