Process for updating a windows service? Automated or is it manual?

强颜欢笑 提交于 2020-01-03 12:30:13

问题


If I have a windows service on a server, what is 'best practise' for updating the service? (say there was a bug in it, or I need to ad more features to it).

Is there a way I could shutdown the service, patch it and get it up and running in a more automated way?

(any links with code would be great)


回答1:


Well, you could always up the version on the installer (if you used one) and run that, from my experience it overlays old versions with the newer one.

Or you could simply shut down the service, copy in the new .exe (and dependencies if any) and start it back up. This could all be done with scripting and the NET start/stop functions I would imagine.

I'm sure there is a better way to do it than this though...




回答2:


Depends how your service is written - monolith EXE - you'll need to stop and restart it using a process of choice e.g. Installer, Script + Service Control, batch and NET STOP/START etc.

If you structure it a little differently e.g. bootstrap EXE loading your service implementation as modules that can be unloaded/reloaded then you can have a different conversation. This is of course a quite a bit more complicated.

I've had some success in C# with a hosting solution like this, similar conversation here:

I want my C# Windows Service to automatically update itself




回答3:


InstallShield supports Windows Services. Leveraging installers will make your task much simpler.



来源:https://stackoverflow.com/questions/246886/process-for-updating-a-windows-service-automated-or-is-it-manual

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!