Play Framework 2多个生产实例

时间:2013-02-24 00:12:56

标签: playframework production-environment multiple-instances playframework-2.1

我创建了两个单独的Play!框架2.1.0应用程序:一个front-end和一个cms,它应该在不同的端口上运行。这些项目共享大量代码,并连接到同一个数据库(具有相同的凭据)。

我用play dist打包了两个项目。我可以开始一个正常(front-end/start -Dhttp.port=1234 &),它创建一个PID文件并按预期运行。

然而,只要我启动另一个项目(back-end/start -Dhttp.port=5678 &),我就会看到该项目开始,但第一个项目被杀死了!

两个项目在彼此独立时工作正常,我开始它们的顺序似乎没有区别。

我更改了application secret以便它们不同。

请注意,第一个进程在尝试在浏览器中访问时会被杀死(在验证第二个进程正在运行之后),但它的PID文件永远不会被删除。

编辑: 如下所示,我在两个终端中运行了两个应用程序,这就是发生的事情:

./start -Dhttp.port=9000 -Dlogger.root=DEBUG -Dlogger.play=DEBUG -Dlogger.application=DEBUG
Play server process ID is 12870
[debug] c.j.b.BoneCPDataSource - JDBC URL = jdbc:mysql://localhost/hp?useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci, Username = hp, partitions = 1, max (per partition) = 30, min (per partition) = 5, helper threads = 0, idle max age = 10 min, idle test period = 1 min
[info] play - database [default] connected at jdbc:mysql://localhost/hp?useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci
[debug] o.r.Reflections - going to scan these urls:
jar:file:/var/play-apps/hp-frontend-1.0/lib/hp-frontend_2.10-1.0.jar!/
jar:file:/var/play-apps/hp-frontend-1.0/lib/play.play_2.10-2.1.0.jar!/

[info] o.r.Reflections - Reflections took 213 ms to scan 2 urls, producing 12 keys and 24 values 
[info] c.a.e.s.c.DefaultServerFactory - DatabasePlatform name:default platform:mysql
[debug] c.a.e.c.AbstractNamingConvention - Using maxConstraintNameLength of 64
[debug] c.a.e.s.l.t.ThreadPool - ThreadPool grow created [Ebean-default.0] size[0]
[debug] c.a.e.a.ClassLoadContext - Context and Caller ClassLoader's same instance of sun.misc.Launcher$AppClassLoader
[info] c.a.e.s.s.SubClassManager - SubClassFactory parent ClassLoader       [sun.misc.Launcher$AppClassLoader]
[debug] c.a.e.a.ClassLoadContext - Context and Caller ClassLoader's same instance of sun.misc.Launcher$AppClassLoader
[debug] c.a.e.s.t.DefaultTypeManager - Registering Joda data types
[debug] c.a.e.s.d.BeanDescriptorManager - BeanPersistControllers[0] BeanFinders[0] BeanPersistListeners[0] BeanQueryAdapters[0]
[debug] c.a.e.s.d.p.DeployCreateProperties - Skipping transient field _ebean_identity in play.db.ebean.Model
[debug] c.a.e.s.d.p.DeployCreateProperties - Skipping transient field _ebean_identity in play.db.ebean.Model
[debug] c.a.e.s.d.p.DeployCreateProperties - Skipping transient field _ebean_identity in play.db.ebean.Model
[info] c.a.e.s.d.BeanDescriptorManager - Explicit sequence on models.CmsPage but not supported by DB Platform - ignored
[info] c.a.e.s.d.BeanDescriptorManager - Explicit sequence on models.Image but not supported by DB Platform - ignored
[debug] c.a.e.s.d.BeanDescriptor - BeanDescriptor initialise models.CmsPage
[debug] c.a.e.s.d.BeanDescriptor - BeanDescriptor initialise models.Image
[debug] c.a.e.s.d.BeanDescriptor - BeanDescriptor initialise models.PagesImages
[info] c.a.e.s.d.BeanDescriptorManager - Entities enhanced[3] subclassed[0]
[debug] j.m.mbeanserver - ObjectName = JMImplementation:type=MBeanServerDelegate
[debug] j.m.mbeanserver - name = JMImplementation:type=MBeanServerDelegate
[debug] j.m.mbeanserver - Send create notification of object JMImplementation:type=MBeanServerDelegate
[debug] j.m.mbeanserver - JMX.mbean.registered JMImplementation:type=MBeanServerDelegate
[debug] j.m.mbeanserver - ObjectName = Ebean:server=default2,function=Logging
[debug] j.m.mbeanserver - name = Ebean:server=default2,function=Logging
[debug] j.m.mbeanserver - Send create notification of object Ebean:function=Logging,server=default2
[debug] j.m.mbeanserver - JMX.mbean.registered Ebean:server=default2,function=Logging
[debug] j.m.mbeanserver - ObjectName = Ebean:server=default2,key=AutoFetch
[debug] j.m.mbeanserver - name = Ebean:server=default2,key=AutoFetch
[debug] j.m.mbeanserver - Send create notification of object  Ebean:key=AutoFetch,server=default2
[debug] j.m.mbeanserver - JMX.mbean.registered Ebean:server=default2,key=AutoFetch
[debug] c.a.ebean.Ebean - GlobalProperties.isSkipPrimaryServer()
[debug] n.s.e.c.ConfigurationFactory - Configuring ehcache from ehcache.xml found in the classpath: jar:file:/var/play-apps/hp-frontend-1.0/lib/play.play_2.10-2.1.0.jar!/ehcache.xml
[debug] n.s.e.c.ConfigurationFactory - Configuring ehcache from URL: jar:file:/var/play-apps/hp-frontend-1.0/lib/play.play_2.10-2.1.0.jar!/ehcache.xml
[debug] n.s.e.c.ConfigurationFactory - Configuring ehcache from InputStream
[debug] n.s.e.c.BeanHandler - Ignoring ehcache attribute xmlns:xsi
[debug] n.s.e.c.BeanHandler - Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
[debug] n.s.e.CacheManager - Creating new CacheManager with default config
[debug] n.s.e.u.PropertyUtil - propertiesString is null.
[debug] n.s.e.c.ConfigurationHelper - No CacheManagerEventListenerFactory class  specified. Skipping...
[debug] n.s.e.Cache - No BootstrapCacheLoaderFactory class specified. Skipping...
[debug] n.s.e.Cache - CacheWriter factory not configured. Skipping...
[debug] n.s.e.c.ConfigurationHelper - No CacheExceptionHandlerFactory class specified.  Skipping...
[debug] n.s.e.s.MemoryStore - Initialized net.sf.ehcache.store.NotifyingMemoryStore for play
[debug] n.s.e.Cache - Initialised cache: play
[debug] n.s.e.c.ConfigurationHelper - CacheDecoratorFactory not configured for defaultCache. Skipping for 'play'.
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
---> Browsed to :9000 here. Waited a minute, then this appeared:
Killed

第二个过程:

 ./start -Dhttp.port=9010 -Dlogger.play=DEBUG
Play server process ID is 12758
[info] play - database [default] connected at jdbc:mysql://localhost/hp?    useUnicode=yes&characterEncoding=UTF-8&connectionCollation=utf8_general_ci
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9010
->Here, I browsed to :9010 and after 30 secs it started working
^C

(调试输出完全相同,因此在此处省略)

我多次尝试了这个过程,结果有一些细微的变化:当等待第一个应用程序在启动第二个之前达到'侦听HTTP'时,第二个永远不会超过'数据库[默认]连接'。

1 个答案:

答案 0 :(得分:0)

你的问题很奇怪,你应该能够在一次启动这两个应用程序,应该没有问题。在不同的端口上运行不同的应用程序(甚至在许多情况下运行相同的应用程序)是非常常见的情况,我甚至无法想象导致所述行为的原因。

RUNNING_PID文件保持未删除的事实表明,发生了一些异常程序终止,因此可能不允许某些元素与其他虚拟机共享某些资源。

最有可能在日志和/或终端中找到它。启动没有&字符的应用程序 - 因此它会将日志直接保存在终端中 - 检查第一个应用程序被杀后的内容。