Added function to flush to log to file
Deamon is catching SIGTERM