2

I have a web server cluster (windows 2008) that collects usage data from clients. The servers all batch the data and send after a certain time or amount of data. The problem is we are using AWS auto-scaling, and the machine can be shut down at any time. I would like to detect a shutdown event and send the usage data to the database before the application is killed. Does anyone know if this is possible?

3 Answers 3

1

I would say, you can perform these tasks (in code/ yourself) when your server goes back up.

Otherwise look here http://social.technet.microsoft.com/Forums/windowsserver/en-US/bd8ea190-9bf4-4915-8ed9-96ee5d6f336a/when-are-windows-server-20032008-shutdown-scripts-run-in-the-shutdown-process

Sign up to request clarification or add additional context in comments.

2 Comments

The server does not go back up, when they are shutdown they are terminated. I've trying to shut the site down in a batch file as you suggest, but I'm running into timing issues stackoverflow.com/questions/17733989/…
0

You can subscribe to this event and perform your logic before the application is shutdown.

Application.Current.Exit +=DoSomething;

1 Comment

Tried that. It works if the website is stopped manually, but not on a Windows shutdown. May need to modify the Windows shutdown policy so that it stops the site during a shutdown, as suggested by T.S.'s link.
0

WebActivator is NuGet package designed to clean up application Start and Shutdown registrations.

This will register your MyStaticClass.Start() and MyStaticClass.Shutdown() methods:

[assembly: WebActivator.PostApplicationStartMethod(typeof(MyStaticClass), "Start")]
[assembly: WebActivator.ApplicationShutdownMethod(typeof(MyStaticClass), "Shutdown")]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.