Write PIDFILE in rake task.

I tried to follow the conversation in #715 and re-implement writing a PIDFILE. 

I wrote the PIDFILE in a separate task because I think that is what was intended by d5c34036 and ono@6790e8c, but I don't have the problem that those were trying to solve, and it kind of feels weird, so I'm definitely open to changes.