From https://github.com/uecode/daemon-bundle