4

I have question about a process I start.

I start the process with Process.Start() method. The process is windows form application that has no GUI. I start the process from a web application that runs on it's own application pool (running as LocalSystem) on IIS.

The process starts without problem but after a while I can see in the logs the process stops doing it's job (no logging occurs). If I stop the application pool from which I started the process and start the pool again (doing nothing else) the process starts from where it stopped. I can see this from the logs where it stopped.

I don't have any dependencies to the parent (web app). I am not waiting for anything in the child process. It only does a lot of API calls to another server. The code actually worked flawless when it was running as thread. I changed to a child process because I wanted it to run LONG jobs. IIS just shut me down if I used worker process.

So anybody nows what causes this strange behavior?

John Isaiah Carmona
  • 5,260
  • 10
  • 45
  • 79
Arin
  • 632
  • 6
  • 16
  • Doe's the process just hang or terminated completely, check in _taskman_? – John Isaiah Carmona Jun 05 '12 at 08:23
  • No it is still is running because I can see the process in task manager. As soon as the pool is recycled the process continues from where it "stopped/paused". – Arin Jun 07 '12 at 13:02

1 Answers1

3

IIS is welcome to recycle the application pool any time it wants to. This is what is stopping your process.

You should move your process into its own application that runs as a Windows Service.

Katie Kilian
  • 6,815
  • 5
  • 41
  • 64
  • But I start a separate process. It's not dependent of IIS application pool. I can even see a process in task manager that runs on the system user. And its not actually stopping its there in task manager its just stopped working. As soon as i recycle the pool it kicks in – Arin Jun 07 '12 at 12:59
  • My suspicion is that Process.Start() spawns the new process as a child of the ASP.NET parent process. I did some quick googling to confirm this, but didn't find what I was looking for before I had to give up (real work calls ATM). That is my suspicion; hopefully that helps. Let me know! I'm interested. – Katie Kilian Jun 07 '12 at 14:27
  • ... in case that last comment wasn't clear, my thought is, if the new process is a child of the ASP.NET process, then the child processes are getting shut down when IIS recycles the parent process running as the ASP.NET app pool. – Katie Kilian Jun 07 '12 at 14:28
  • Also, FWIW, I still think that running the long process as a Windows Service is a cleaner design. But I know that opinions vary, and sometimes you don't have that option for various reasons (politics with network admins, deployment issues, etc). – Katie Kilian Jun 07 '12 at 14:30
  • Actually the process is never shutdown. I can still see the process in task manager while it's "stopped/paused". As soon as I manually recycle the application pool the process kicks in (I can see that in the logs). Anyway it might be as you say that the process is some kind of child of ASP.NET parent process thats why its paused. I will look into that or look at implementing it as a service instead. – Arin Jun 07 '12 at 15:39
  • Thanks for all the help but the problem is solved now :) Something with Log4net was pausing the process. I tried to disable log4net and that actually helped! I still needed logging so I disabled the console appender (just a random test) and now the spawned process runs as expected! Somehow the console appender blocked the code execution. Anybody got an idea why? – Arin Jun 08 '12 at 08:11