4

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)

winwaed
  • 7,645
  • 6
  • 36
  • 81

1 Answers1

6

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
Wade Matveyenko
  • 4,290
  • 1
  • 23
  • 27
  • Thanks - yes the blog post (and part 2) are useful. I'm not the only person who finds AWS documentation poor - at least Amazon seem to recognise it in their blogs - shame Google doesn't do a good job of indexing them! Off to research the writing of Windows Services (shouldn't need many changes), and I'll report back later in the week once I've given it all a go... – winwaed Oct 22 '13 at 01:28
  • I'm marking this as the answer. I've changed my project to a service (and that runs fine locally on my PC). I also have it deploying to EB. My upload file is just a zip with the .ebextensions config info. The actual service exe, config, DLLs, and data files are passed in a S3-hosted zip. However I'm currently getting a "FileNotFound" exception at the beginning of my main processing thread. At least the service is starting and it is getting that far! Although I'm hitting a new brick wall, I think new question(s) are more appropriate. – winwaed Oct 25 '13 at 14:54