Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages of running an application as a service

Sometimes I see that some applications allow themselves to be run as a service on Windows, 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.
like image 485
detunized Avatar asked Jan 24 '11 18:01

detunized


3 Answers

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.

like image 162
Greg Hewgill Avatar answered Nov 15 '22 15:11

Greg Hewgill


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.

like image 20
ryan42 Avatar answered Nov 15 '22 13:11

ryan42


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.

like image 28
John Avatar answered Nov 15 '22 15:11

John