如何在Azure App Service中运行Wildfly

时间:2016-05-18 17:55:30

标签: azure java-ee wildfly azure-web-sites

根据文档[https://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/],我们可以运行自定义Java应用程序。通过以下设置,Wildfly运行良好,但不断重新启动,因此我无法从[http://app-service.azurewebsites.net/]访问该网站。

将源发布为“Local Git Repository”

1. git clone https://user@<app-service>.scm.azurewebsites.net:443/<app-service>.git
2. Copy Wildfly under bin folder
3. Create web.config under root folder
4. git add .
5. git commit -m "initial"
6. git push origin master

的web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%HOME%\site\wwwroot\bin\wildfly\bin\standalone.bat"
        arguments="">
      <environmentVariables>
        <environmentVariable name="SERVER_OPTS" value="-Djboss.http.port=%HTTP_PLATFORM_PORT%" />
        <environmentVariable name="JBOSS_HOME" value="%HOME%\site\wwwroot\bin\wildfly" />
        <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true" />
      </environmentVariables>
    </httpPlatform>
  </system.webServer>
</configuration>

日志文件

1. Connect to ftp://<app-service>\user@waws-prod-sn1-033.ftp.azurewebsites.windows.net
2. Check Wildfly log at path: /site/wwwroot/bin/wildfly/standalon/log

日志摘要

2016-05-18 18:17:16,539 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: Keycloak 1.9.1.Final (WildFly Core 2.0.10.Final) starting
2016-05-18 18:17:16,539 DEBUG [org.jboss.as.config] (MSC service thread 1-1) Configured system properties:
    awt.toolkit = sun.awt.windows.WToolkit
    file.encoding = Cp1252
    file.encoding.pkg = sun.io
    ...
2016-05-18 18:17:16,549 DEBUG [org.jboss.as.config] (MSC service thread 1-1) VM Arguments: -Dprogram.name=standalone.bat -Djava.net.preferIPv4Stack=true -Dorg.jboss.boot.log.file=D:\home\site\wwwroot\bin\keycloak\standalone\log\server.log -Dlogging.configuration=file:D:\home\site\wwwroot\bin\keycloak\standalone\configuration/logging.properties 
2016-05-18 18:17:22,976 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
2016-05-18 18:17:23,095 INFO  [org.xnio] (MSC service thread 1-2) XNIO version 3.3.4.Final
2016-05-18 18:17:23,193 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.3.4.Final
2016-05-18 18:17:23,347 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 4.0.18.Final
...
2016-05-18 18:18:07,318 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 48) WFLYUT0021: Registered web context: /auth
2016-05-18 18:18:07,457 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 45) WFLYSRV0010: Deployed "keycloak-server.war" (runtime-name : "keycloak-server.war")
2016-05-18 18:18:07,799 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
2016-05-18 18:18:07,799 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
2016-05-18 18:18:07,799 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Keycloak 1.9.1.Final (WildFly Core 2.0.10.Final) started in 53968ms - Started 416 of 782 services (526 services are lazy, passive or on-demand)

1 个答案:

答案 0 :(得分:0)

问题在于动态端口(不是8080)。使用动态端口分配的正确配置如下。请注意参数的变化=&#34; -Djboss.http.port =%HTTP_PLATFORM_PORT%&#34;。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%HOME%\site\wwwroot\bin\wildfly\bin\standalone.bat"
        arguments="-Djboss.http.port=%HTTP_PLATFORM_PORT%" startupTimeLimit="120" startupRetryCount="2" requestTimeout="00:10:00" stdoutLogEnabled="true">
      <environmentVariables>
        <environmentVariable name="JBOSS_HOME" value="%HOME%\site\wwwroot\bin\wildfly" />
      </environmentVariables>
    </httpPlatform>
  </system.webServer>
</configuration>