Improve api build

This changes API build script so that the log file and temporary directories are in place before rake tasks are run that could theoretically write log entries or create temporary files.

It also adds some rake tasks to clear out the delayed job queue, and QA reports directory, because there can be upgrade issues if that is not done and changes have been made to reports.

There are some subtleties that may not be getting addressed, but this should cover most cases of upgrading the QA app.

Yes, we'll want to make sure that all active topic branches have been rebased on that change, or have had it cherry-picked.