Convert existing code to use logger.h.
Write pid file even in foreground mode.