I am working on a wider web application using AWS infrastructure. It has two 'worker' components which read work from SQS and write the results to an RDS database. One of these is Python and I already have this working on a single Elastic Beanstalk instance. The second uses .NET and I am currently working out how to deploy it. For production, both will be elastic with multiple instances.
As these processing components are not web applications (i.e. they do not respond to http requests), I have to explicitly start them off. For the Python example, I use the .ebextensions file:
container_commands:
02-start-command:
command: "nohup python scannerapp.py > foo.out 2> foo.err < /dev/null &"
leader_only: false
How can I do the same with a .NET application? As with the above Python/Linux example, the Windows configuration file supports 'Commands' and 'Container Commands' but these are intended for startup programs (e.g. installers). Ie. startup/installation does not complete until the command exits. The nohup command solves the problem for Python. How do I do this with a .NET worker application?
Or is it too difficult, and I should consider porting to MONO first and using one of the Linux options? (MONO running costs are expected to be more cost effective, so it is already on the to-do list for the future)
You can do the same thing with the .NET container. You would have to install your worker as a Windows service. Check out this blog post, which explains it in detail. At the high level you would have an .ebextensions file that contains:
sources:
c:/AppSupport/MyAppJanitor: http://s3.amazonaws.com/my-app-support/MyAppJanitor.zip
commands:
install-janitor:
command: C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\installutil MyAppJanitor.exe
cwd: c:/AppSupport/MyAppJanitor
waitForCompletion:0
services:
windows:
MyAppJanitor:
enabled: true
ensureRunning: true
commands: install-janitor
来源:https://stackoverflow.com/questions/19500247/deploying-a-net-worker-app-with-elastic-beanstalk