在 IIS 版本 10 中使用 httpPlatform Handler 的某些应用程序无法启动 Python Flask 应用程序

问题描述 投票:0回答:1

我有多个具有类似 python Flask 应用程序脚本的应用程序托管在 IIS\默认网站中。只有首先创建的应用程序才能按预期工作,不幸的是,其他后续的 Flask 应用程序没有运行。

当回收相应的应用程序池时,我仅在事件查看器中遇到以下错误。

Log Name:      Application
Source:        HttpPlatformHandler
Date:          10/27/2023 3:46:44 PM
Event ID:      1000
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      
Description:
The description for Event ID 1000 from source HttpPlatformHandler cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event: 

Process '10260' failed to start. Port = 20173, Error Code = '-2147023436'.

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="HttpPlatformHandler" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>0</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2023-10-27T10:16:44.326060800Z" />
    <EventRecordID>1926695</EventRecordID>
    <Channel>Application</Channel>
    <Computer>BAVNAPPCNV01.PEARL.COM</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Process '10260' failed to start. Port = 20173, Error Code = '-2147023436'.</Data>
  </EventData>
</Event>

web.config 文件

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpPlatform processPath="D:\Program Files (x86)\Utilities\report\report\env\Scripts\python.exe" arguments="-m flask run --port 4001">
            <environmentVariables>
                <environmentVariable name="FLASK_APP" value="report.py" />
            </environmentVariables>
        </httpPlatform>
        <handlers>
            <add name="reportHttpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" scriptProcessor="D:\Program Files (x86)\Utilities\report\report\env\Scripts\python.exe" resourceType="Unspecified" />
        </handlers>
    </system.webServer>
</configuration>

我尝试卸载并重新安装httpPlatformHandler,甚至重新启动服务器。

python-3.x flask iis-10 httpplatformhandler
1个回答
0
投票

尝试重新安装 http 处理程序,使用下面的 web.config 文件:

<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <httpPlatform processPath="C:\Python311\python.exe" arguments="-m flask run --port %HTTP_PLATFORM_PORT%" startupTimeLimit="20" stdoutLogEnabled="true" stdoutLogFile=".\test.log">
        </httpPlatform>
    </system.webServer>
</configuration>

为python exe文件所在的站点根文件夹和python文件夹分配iis_iusrs和iusr完全控制权限。

© www.soinside.com 2019 - 2024. All rights reserved.