added pid and pid file handling

Signed-off-by: winlu <derwinlu@gmail.com>