Deployment options

Play applications can be deployed virtually anywhere: inside Servlet containers, as standalone servers, in Google Application Engine, Stack, a Cloud, etc...

Standalone Play applications

The simplest and the more robust way is to simply run your Play application without any container. You can use a frontal HTTP server like Lighttpd or Apache if you need more advanced HTTP features like virtual hosting.

The built-in HTTP server can serve thousands of HTTP requests per second so it will never be the performance bottleneck. Moreover it uses a more efficient threading model (where a Servlet container uses 1 thread per request). Different modules allow you to use different servers (Grizzly, Netty, etc...) as well.

Those servers support long polling and allow to manage very long requests (waiting for a long task to complete), and direct streaming of File objects (and any InputStream if you specify the Content-Length), without blocking the execution thread.

You will have less problems running your application this way, as you will use the same environment that you used during the development process. A lot of bugs can be discovered only when you deploy to a JEE application server (different home dir, classloader issues, library conflicts, etc...).

Please refer to the ‘Put your application in production‘ page for more information.

Java EE application servers

Your Play application can also run inside your favorite application server. Most application servers are supported out of the box.

Application server compatibility matrix

JBoss 4.2.x JBoss 5.x JBoss 6M2 Glasshfish v3 IBM Websphere 6.1 IBM Websphere 7 Geronimo 2.x Tomcat 6.x Jetty 7.x Resin 4.0.5
? ? ? ? ? ? ? ? ? ?

These application server are known to work with Play 1.1 but feel free to report any other working deployment.

Deploying

You need to package your application as a war file. This is easily done with the following command:

play war myapp -o myapp.war

Please note that your application server must support deployment of exploded WAR files.

You are now ready to deploy your application.

You are advised to ‘isolate’ your Play application from the other applications to avoid version mismatches between the application libraries. This step is not standardized by the JEE / Servlet Container specification, and is therefore vendor specific.

We recommend you refer to your application server manual in order to ‘isolate’ your WAR. As an example below is how you isolate a war file in JBoss Application server. Note that this is an optional step:

Insert the following content (or create the file) in your application war directory at myapp.war/WEB-INF/jboss-web.xml:


<jboss-web>
 <class-loading java2classloadingcompliance="false">
 <loader-repository>
 com.example:archive=unique-archive-name
 <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
 </loader-repository>
</class-loading>
</jboss-web>

Replace com.example:archive=unique-archive-name with whatever you wish as long as it is unique.

Datasource

Play also supports Datasource and resource look-up. To use a JNDI Datasource, configure the Play database plugin (play.db.DBPlugin) in application.conf as shown below:

db=java:comp/env/jdbc/mydb
jpa.dialect=org.hibernate.dialect.Oracle10gDialect
jpa.ddl=verify

The database plugin detects the pattern “db=java:” and will unactivate the default JDBC system.

Custom web.xml

Some application servers, such as IBM Websphere, require you to declare a datasource in aresource-ref element in the Servlet API’s web.xml configuration file. By default, web.xml is a file that is generated by Play when you execute the play war command. To customise the generated web.xml, generate the exploded WAR version, then copy the generated web.xml file to the war/WEB-INF folder in your application. The next time you will execute the play war command, it will copy your customweb.xml from to the generated folder.

For instance, to declare a datasource for IBM Websphere 7, we can declare a resource-ref in ourwar/WEB-INF/web.xml file:

<?xml version="1.0" ?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
  <display-name>Play! (%APPLICATION_NAME%)</display-name>
  <context-param>
    <param-name>play.id</param-name>
    <param-value>%PLAY_ID%</param-value>
  </context-param>
  <listener>
      <listener-class>play.server.ServletWrapper</listener-class>
  </listener>
  <servlet>
    <servlet-name>play</servlet-name>
    <servlet-class>play.server.ServletWrapper</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>play</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <resource-ref>
        <description>Play Datasource for testDatasource</description>
        <res-ref-name>jdbc/mydb</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
  </resource-ref>
</web-app>

Google Application Engine (GAE)

A Play application can very easily be deployed to the GAE. It is a matter of installing the relevant GAE module.

play install gae

Deploying to the Google Application Engine is again really easy:

play gae:deploy myapp

Refer to the module documentation for more information.

Stax cloud hosting platform

Easy deployment to the Stax cloud hosting platform: again nothing could be easier. Install the Stax module and deploy within seconds.

Refer to the module documentation for more information.

时间: 2024-08-29 06:14:54

Deployment options的相关文章

WAN Optimizatoin - SteelHead Appliance Deployment

Part 1: Cabling(Straight through VS Crossover) The primary interface is typically used for managemnt purposes, datastore synchronization(if possible), and for server-side out-of-path configuratoins. (Straight-through cable to switch) the LAN and WAN

Introduction to Microservices

原文出自:http://nginx.com/blog/introduction-to-microservices .我在其中加入了简单的翻译和自己的一些看法.  This is a guest post by Chris Richardson. Chris is the founder of the original CloudFoundry.com, an early Java PaaS (Platform-as-a-Service) for Amazon EC2. He now consul

Delphi ActiveForm发布全攻略

论坛上很多朋友(也包括我)提到ActiveForm的发布问题,都没有得到很好的解决.下面是本人开发ActiveForm的一点经验,拿出来跟大家分享,开发环境为 Win2000Server,IIS5.0,BCB5.0,Delphi也差不多的了. 先说说程序的开发,如果是从一般应用程序移植而来,注意所有的窗体(除了主窗体)都要动态创建,工程的选项里面是没有Auto-Create Forms的选项给你的.还有,很重要的就是要实现IObjectSafety接口,其实很简单,加上两句话就可以了(for B

Delphi 编写ActiveForm窗体工程知识和样例(开发浏览器客户端应用程序)(有详细步骤)

一.基础知识介绍: 1.ActiveForm的基础知识介绍: 在Delphi中,ActiveForm是封装了Delphi Form的一种ActiveX控件.ActiveForm其实是一种标准的Delphi From(ActiveForm继承自TForm).ActiveForm中可能会包含某些VCL或者ActiveX组件,包括用户自定义的组件. 就像“标准的”Windows应用程序一样,我们也可以向ActiveForm中添加代码以及对事件作出应答.唯一的区别是,ActiveForm的标题栏(tit

Jersey(1.19.1) - Deploying a RESTful Web Service

JAX-RS provides a deployment agnostic abstract class Application for declaring root resource and provider classes, and root resource and provider singleton instances. A Web service may extend this class to declare root resource and provider classes.

对“用微服务架构开发应用”的注解

下文是对 Chris Richardson(CloudFoundry 的创建者) 在 SlideShare 分享的"Developing applications with a microservice architecture"(需要科学上网,不会的同学学习吧,为了你们好,此处不发表评论)的注解. 在全球最大的视频网站上也有 Chris Richardson 的演讲的视频,自己找吧.我还没来及看,而且我也是普通码农一个,所以下面的内容难免有一些谬误,但技术胜在交流,所以下发表出来.以

python远程调试

from: https://www.xncoding.com/2016/05/26/python/pycharm-remote.html 你是否经常要在Windows 7或MAC OS X上面开发Python或Web应用程序,但是它们最后需要在linux上面来运行呢? 我们经常会碰到开发时没有问题但是到了正式的Linux环境下面却出现问题.那么怎样保证开发环境跟运行环境的一致呢? 通常有两种方法解决.一种是使用PyCharm内置支持的Vagrant,这个教程可以参考Vagrant开发环境配置.

Windows Server 2016 Software-Defined-Datacenter Features

Windows Server 2016 is the cloud-ready operating system (OS) that delivers new layers of security and Microsoft Azure-inspired innovation for the applications and infrastructure that power your business. One of the important feature is Softwzre-defin

O`Reilly FreeBook:数据湖构架 简介

O`Reilly 的 < Architecting Data Lakes Data Management Architectures for Advanced Business Use Cases >,全面介绍了数据湖的构架.工作机理.构建与管理.规划.价值.展望等诸多方面的内容. 其目录如下: 1. Overview What Is a Data Lake? Data Management and Governance in the Data Lake How to Deploy a Dat