0

我创建了两个单独的 Play!框架 2.1.0 应用程序: afront-end和 a 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”时,第二个应用程序从未通过“数据库 [默认] 连接”。

4

1 回答 1

0

您的问题很奇怪,您应该能够同时启动两个应用程序并且应该没有问题。在不同的端口上运行不同的应用程序(甚至在许多情况下运行相同的应用程序)是很常见的情况,我什至无法想象是什么导致了所描述的行为。

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

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

于 2013-02-24T10:32:36.867 回答