0

我创建了两个独立的Play!框架2.1.0应用程序:一个front-end和一个cms,它应该在不同的端口上运行。这些项目共享很多代码,并连接到相同的数据库(使用相同的凭据)。Play Framework 2多个生产实例

我用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 

(调试输出是完全相同,所以在这里省略)

我尝试了多次的过程,结果有一些小的变化:当等待第一个应用程序到达'听fo r HTTP'在启动第二个之前,第二个从未过去'数据库[默认]连接'。

+0

我创建了两个播放项目并在彼此之后启动它们,但我无法再现您的错误。你的日志里有什么? – Schleichardt 2013-02-24 07:06:35

回答

0

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

事实上,RUNNING_PID文件保持未删除状态表示存在一些异常程序终止发生,所以可能有些元素不允许与其他虚拟机共享一些资源。

很可能它可以在日志和或终端中找到。在没有&字符的情况下启动应用程序 - 因此它会将日志直接保存在终端中 - 请检查在第一个应用程序被终止后它说的是什么。

+0

我按照你的建议,并添加了对我的问题的答复 – 2013-02-25 21:03:29