开发者

Restarting IIS6 - Python

I'm serving a Django app behind IIS 6. I'm wondering if I can restart IIS 6 within Python/Django and what 开发者_JAVA技巧one of the best ways to do would be.

Help would be great!


Besides what's already suggested, you can also use WMI via either the Win32_Service or the IIsWebService class, which inherits from it. There is a Python WMI wrapper available, which is based on pywin32.

UPDATE: A quick test of the following worked for me.

import wmi

c = wmi.WMI()

for service in c.Win32_Service(Name="W3SVC"):
    result, = service.StopService()

I didn't test the next piece of code, but something like this should also work:

for service in c.IIsWebService():
    result, = service.StopService()

You can see the documentation for the return values from the StopService and StartService methods.


The following post shows how to control Windows services from Python: http://fuzzytolerance.info/code/using-python-to-manage-windows-services/

You should be able that to restart the IIS web publishing service (known as 'w3svc')


I think that you can execute an iisreset via a commandline. I've never tried that with Django but it should work and be quite simple to implement.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜