Tuesday, June 28, 2011

What can you do if your AOS service is in the stopping state?

For a routine maintenance job you want to bring the AOS server down.  So you stop the service and then... things go terribly wrong.  The Windows service does not stop and remains in the stopping state. 
So now what?  You cannot stop the service, you cannot start it.  Is a server reboot an option?

If there is only one AOS instance installed on your server, it's easy.  By using the taskmanager in Windows, kill process Ax32Serv.exe.

If there are multiple AOS instances on your server, it's a bit more tricky.  All your AOS instances have a process running with the same name, Ax32Serv.exe (Can you afford to kill the wrong process, shutting down the wrong AOS?).


1.  So first you need to identify the correct process.  You can do this by using the sc command.

For this we need to know the precise service name.  We find this piece of information in the Services window, by clicking on the Properties of the AOS service (in stopping state).  Note the name, it will be something like AOS50$nn (for Dynamics Ax 2009).



2.  With this info, query the current running services.  You can use the service controller utility sc for this.
Syntax:

   sc queryex aos50$nn   (use the service name from the previous step)



This gives you the exact PID or process id.

3.  Now we are ready to kill the task:

   TASKKILL /PID nnn /F   (where nnn is the process id from the previous step)

Refresh your screen with the Windows services, and you'll see that the AOS service is no longer in the stopped state.

Please: Use the instructions above at your own risk!
If this happens pretty frequent, look for the error cause instead of just applying this workaround. 
Do you know a better remedy?  Post it in the comments!

6 comments:

  1. Maybe you can do the same thing but from the winapi inside AX. You need to also think of what the backend implications are though when killing a service especially now with the server side changes to AX2012. How does this effect the DB?

    ReplyDelete
  2. On newer versions of windows, in the task manager, you can right click the proces, choose properties, and check the Location property on the General tab. This path usually contains the name of the environment too if you named it right. Then you can right click that process again and choose 'end process tree'.

    ReplyDelete
  3. Add the "Image Path Name" colum to processes tab in Task Manager to find the right process quickly.

    ReplyDelete
  4. Nice article, but some one tell me the reason of AOS stopping automatically.

    ReplyDelete
  5. Great blog. Thanks for share this post. It may helpful for all newbie bloggers, i really appreciate.Microsoft Dynamics Ax Partners

    ReplyDelete