To run background jobs on AppHarbor, simply add a console application to your solution and a background worker to your application subscription.
If you push code without a website, we'll automatically add a background worker to your application. If your project includes a website, you'll have to add the background worker manually by browsing to the "Subscription" page from the application dashboard.
AppHarbor will launch and monitor all executables found in the build artifact (including references). If a process terminates with a non-zero exit code, it will be relaunched with a short delay. If the process terminates a zero exit code, we'll assume the process is done processing and not start it again until next time the application is deployed.
All executables run by a single background worker compete for the same resource allocation (i.e. having multiple copies of the same executable run by a single background worker will not get you more resources).
Configuration transformation works as for websites, so all configuration variables and add-on configuration will be injected into .config files. Note that the build causes a config file re-name for console application config files so that the configuration file name will generally be ExecutableName.exe.config. If there's no matching transform for that, no transformation will take place. You can get around this renaming the transformation to match the runtime configuration file name.
You can stop executables from being deployed to background workers by including the following in the corresponding configuration file(s) for the executable(s) you don't want to run:
<add key="appharbor.deploy_as_background_worker" value="false"/>
If you go to your application dashboard and navigate to the "Subscription" page, you can scale down the number of background workers to zero. This will terminate all background worker processes.
Temporary files can be written to the
_TemporaryFiles directory from your current directory.
Use something similar to
"_TemporaryFiles") to access it.
Keep in mind that temporary files are wiped on each deployment.
All standard output and standard error is streamed directly to the built-in logging module along with detailed information about the operation of the process manager that runs with your background workers. You can log simply by writing to the console and all you exceptions will automatically be logged. You can find more information in the knowledge base article about logging.
You should make sure that any application run by AppHarbor background workers is idempotent and that it can be run concurrently by multiple background workers without error. Even if you only add one background worker on AppHarbor, the platform may at times run multiple instances of your app, for example if a server is being taken down for maintenance or similar.