开发者

Advantages of running an application as a service

Sometimes I see that some applications allow themselves to be run as a service on Windows开发者_StackOverflow中文版, for example Apache HTTP Server allows that. I always ran it as a regular application and never experienced any problems or limitations.

  • What are the advantages of this?
  • Is there anything that applications is allowed to do or have when it's run as a service?
  • What are the advantages for me as a developer, when I write a service vs. a regular application.


The biggest benefit to running an application as a service is that it will continue running even after the current user logs off (and will start running before a user logs on). Also, services normally run under a local "System" account instead of running under the login of a particular user (although services can, and often are, configured to run under a specific user login, usually dedicated to that purpose).

As a developer, you probably won't notice a lot of difference. Processes running on the desktop are usually easier to debug if something goes wrong. Normally you would set up your application to be able to run in either mode, making it both easy for development and appropriate for deployment.


One thing that comes to my mind is that a service can start before a user logs into the system. I would consider a service to be the ideal way to run a daemon that does not normally have a frontend GUI. It's harder for a user to inadvertently quit, and its out of sight and out of mind.


Services run even when no user is logged on. Applications interact with users.

If you need both, you may need to have two components, one running as a service and one interacting with users.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜