Я создал два отдельных Play! приложения 2.1.0: a front-end
и cms
, который должен работать на разных портах. Проекты имеют много кода и подключаются к одной базе данных (с теми же учетными данными).Play Framework 2 экземпляра нескольких экземпляров
Я упаковал два проекта с помощью play dist
. Я могу начать либо один штраф (front-end/start -Dhttp.port=1234 &
), который создает PID-файл и работает как ожидалось.
Однако, как только я запускаю другой проект (back-end/start -Dhttp.port=5678 &
), я вижу, что проект начинается, но первый проект убит!
Оба проекта прекрасно работают, когда независимы друг от друга, и порядок, в котором я начинаю их, кажется, не имеет значения.
Я изменил application secret
так, чтобы они были разными.
Обратите внимание, что при попытке доступа к нему в браузере первый процесс уничтожается (после проверки того, что второй работал), но это файл PID никогда не удаляется.
Edit: Как предлагается ниже, я побежал оба приложения в двух терминалах, это то, что случилось:
./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 'перед тем, как запустить 2-й, второй никогда не прошёл' database [default] connected '.
Я создал два игровых проекта и начал их после друг друга, но я не могу воспроизвести вашу ошибку. Что в ваших журналах? – Schleichardt