move common code into some helpers

- database related, including model preloading, into helpers/database.rb
- metriks and memory reporting into helpers/reporting.rb
improve the queue log messages