Fix Long running daemon errors

This is a tricky problem.

I've noticed that after the daemon runs for an extended period of time (12+ hours?  Its hard to tell for sure), weird things start to happen.  For example, sites fail to be scanned and are not crawled or processed.  Restarting the daemon fixes this.  I haven't found anything in the logs to pinpoint the error.

I've had similar problems on an application using a long running daemon, which I fixed by using a mysqli persistent connection.  http://www.php.net/manual/en/mysqli.persistconns.php

I'm not confident that this will fix the problem, but it will hopefully get us closer.  I've also improved exception handling to a section of the application which could cause the scan to finish early while masking the underlying error.

Another option would be to regularly restart the daemon process.