I have a tasks table in my db. I want to read data from this table and run tasks. Which one is better whether to have it as windows service or a console application running. The server on which this will be run will not be shutdown
问题:
回答1:
You most likely want to use a windows service.
Benefits:
- You can control the user (and the rights associated with this user account) which starts the process
- An automatically started process means the desktop need to be on, not user logged, for the service to run
- A policy on failure can be defined (try to restart n times run a specific program if fails)
- A dependency can be defined (if you depend on other sevices)
- You can wrap your script in an invisible window
- You can easily start/stop/restart the script (
net start <scriptname>
)
Quoted from here: What is the benefit of developing the application as a windows service?
回答2:
A running console app is not an option, as the others have stated.
If you just want the task run every x minutes the simplest option is a scheduled task using a console application.
A windows service has it's benefits, but is a little bit more complex to implement and deploy. However if your app needs to be 'always on' (e.g. need to react to external triggers, listen to message queue, ...), a windows service is the only option. As the others have said, the services infrastructure also provides more management capabilities, built-in integration with the event log, restart and failover options...
回答3:
Windows service, because it does not require logged-in user.
回答4:
I would say; Windows Services.
In that case (among other things) you don't need a user to be logged in, you can configure it in a matter to restart automatically if it shuts down for some reason and you (could) have extensive rights throughout the system.
回答5:
Windows service generally. Console app will need to be restarted if the server reboots while a windows service can start automatically.
回答6:
You should look at: https://github.com/thedavejay/Self-Installing-Windows-Service
It allows you to debug as a console application and then install it as a windows service.