Isolated tested code in main.cpp
Added two ways of demonizing program

1. From init.d script
2. By using fork() and setsid()