如果存在数据库进化,Bamboo 无法在 playframework 上启动应用程序
Bamboo fail to start up application on playframework if there is Database evolution
我有一个非常烦人的问题,Bamboo 在启动时如何处理激活器(或我的 ssh?),并且数据库发生了变化,它只是认为它失败并退出 ssh,所以我无法按下按钮运行 个进化脚本。
我在 application.conf
文件中使用 play.evolutions.autoApply=true
启用了自动申请进化,在开始命令中我输入了 play.evolutions.db.default.autoApply
没有运气,任何人都可以帮助如何让竹子相信进化可以保留我的激活器运行ning?
我的ci-开始-all.sh:
#!/bin/sh
set -e
. ./ci/ci-set-env.sh
./ci/play-start.sh
set +e
还有我的戏-start.sh :
#!/bin/sh
set -e
echo
echo '****** PLAY START *******'
echo
nohup ./target/universal/stage/bin/webapp -Dplay.evolutions.db.default.autoApply=true -Dhttp.port=$PLAY_PORT -Dconfig.file=conf/cloud.conf &>play.out &
sleep 10
#look for process listening to port TODO: replace with wget and a url
pid=`lsof -Pi tcp:$PLAY_PORT | grep LISTEN | awk '{print }'`
if [ $pid > 0 ];
then
echo [success] Play! started
else
echo ERROR: Play! did not start successfully
#output logfile
cat play.out
exit 1
fi
set +e
我的日志文件:
ERROR: Play! did not start successfully
11-Nov-2015 11:23:20 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
11-Nov-2015 11:23:20 2015-11-11 11:23:12 +0200 1105 INFO application - Creating Pool for datasource 'default'
11-Nov-2015 11:23:20 2015-11-11 11:23:13 +0200 2166 INFO play.api.db.DefaultDBApi - Database [default] connected at jdbc:mysql://localhost/timesheets_dev?zeroDateTimeBehavior=convertToNull
11-Nov-2015 11:23:20 2015-11-11 11:23:14 +0200 2889 WARN p.a.d.e.ApplicationEvolutions - Your production database [default] needs evolutions, including downs!
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 # !!! WARNING! This script contains DOWNS evolutions that are likely destructives
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 # --- Rev:3,Downs - 9cadf53
11-Nov-2015 11:23:20 ALTER TABLE ACCOUNTS DROP users_count;
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 # --- Rev:3,Ups - 79049fc
11-Nov-2015 11:23:20 ALTER TABLE ACCOUNTS ADD users_count int DEFAULT 0 NULL;
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 UPDATE ACCOUNTS a SET users_count = (SELECT COUNT(*) FROM USERS u WHERE u.account_id = a.id and u.is_active = true);
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 2015-11-11 11:23:14 +0200 2896 WARN p.a.d.e.ApplicationEvolutions - Run with -Dplay.evolutions.db.default.autoApply=true and -Dplay.evolutions.db.default.autoApplyDowns=true if you want to run them automatically, including downs (be careful, especially if your down evolutions drop existing data)
11-Nov-2015 11:23:20 Oops, cannot start the server.
11-Nov-2015 11:23:20 @6o4mnmhf7: Database 'default' needs evolution!
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions$$anonfun$play$api$db$evolutions$ApplicationEvolutions$$runEvolutions.apply$mcV$sp(ApplicationEvolutions.scala:68)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.withLock(ApplicationEvolutions.scala:98)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.play$api$db$evolutions$ApplicationEvolutions$$runEvolutions(ApplicationEvolutions.scala:49)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions$$anonfun$start.apply(ApplicationEvolutions.scala:42)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions$$anonfun$start.apply(ApplicationEvolutions.scala:42)
11-Nov-2015 11:23:20 at scala.collection.immutable.List.foreach(List.scala:381)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.start(ApplicationEvolutions.scala:42)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.<init>(ApplicationEvolutions.scala:149)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutionsProvider.get$lzycompute(EvolutionsModule.scala:53)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:53)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:44)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
11-Nov-2015 11:23:20 at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
11-Nov-2015 11:23:20 at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderToInternalFactoryAdapter.call(ProviderToInternalFactoryAdapter.java:46)
11-Nov-2015 11:23:20 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
11-Nov-2015 11:23:20 at com.google.inject.internal.SingletonScope.get(SingletonScope.java:145)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.call(InternalInjectorCreator.java:205)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.call(InternalInjectorCreator.java:199)
11-Nov-2015 11:23:20 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
11-Nov-2015 11:23:20 at com.google.inject.Guice.createInjector(Guice.java:96)
11-Nov-2015 11:23:20 at com.google.inject.Guice.createInjector(Guice.java:73)
11-Nov-2015 11:23:20 at com.google.inject.Guice.createInjector(Guice.java:62)
11-Nov-2015 11:23:20 at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
11-Nov-2015 11:23:20 at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
11-Nov-2015 11:23:20 at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
11-Nov-2015 11:23:20 at play.core.server.ProdServerStart$.start(ProdServerStart.scala:52)
11-Nov-2015 11:23:20 at play.core.server.ProdServerStart$.main(ProdServerStart.scala:27)
11-Nov-2015 11:23:20 at play.core.server.ProdServerStart.main(ProdServerStart.scala)
11-Nov-2015 11:23:20 Failing task since return code of [./ci/ci-start-all.sh] was 1 while expected 0
11-Nov-2015 11:23:20 Finished task 'CI Start All' with result: Failed
11-Nov-2015 11:23:20 Running post build plugin 'npm Cache Cleanup'
11-Nov-2015 11:23:20 Running post build plugin 'NCover Results Collector'
11-Nov-2015 11:23:20 Running post build plugin 'Clover Results Collector'
11-Nov-2015 11:23:20 Running post build plugin 'Artifact Copier'
11-Nov-2015 11:23:20 Publishing an artifact: XXX
11-Nov-2015 11:24:03 Finished publishing of artifact Shared artifact: [XXX], pattern: [**/*] in 43s
11-Nov-2015 11:24:03 Finalising the build...
11-Nov-2015 11:24:03 Stopping timer.
11-Nov-2015 11:24:03 Build XXX-173 completed.
11-Nov-2015 11:24:03 Running on server: post build plugin 'NCover Results Collector'
11-Nov-2015 11:24:03 Running on server: post build plugin 'Clover Delta Calculator'
11-Nov-2015 11:24:03 Running on server: post build plugin 'Maven Dependencies Postprocessor'
11-Nov-2015 11:24:03 Running on server: post build plugin 'Build Hanging Detection Configuration'
11-Nov-2015 11:24:03 All post build plugins have finished
11-Nov-2015 11:24:03 Generating build results summary...
11-Nov-2015 11:24:07 Saving build results to disk...
11-Nov-2015 11:24:07 Indexing build results...
11-Nov-2015 11:24:07 Finished building XXX-173
有时当它是一种破坏性的进化时它会停止,我只是在 application.conf
中添加了以下几行以使其成为 运行 你需要从配置中设置值并强制进化但要小心,你不需要丢失你的数据,如果你只是在开发阶段并且它可以这样做,否则保持 play.evolutions.autoApplyDowns
为假,或者根本不把它保持默认值(这对于生产是假的)
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=true
# You can disable evolutions for a specific datasource if necessary
play.evolutions.db.default.enabled=true
# this is safe to use if there is no "DOWNS" otherwise it will fail to start
play.evolutions.autoApply = true
# BECAREFUL ITS DANGROUS DON'T USE IN PRODUCTION
play.evolutions.autoApplyDowns = true
我有一个非常烦人的问题,Bamboo 在启动时如何处理激活器(或我的 ssh?),并且数据库发生了变化,它只是认为它失败并退出 ssh,所以我无法按下按钮运行 个进化脚本。
我在 application.conf
文件中使用 play.evolutions.autoApply=true
启用了自动申请进化,在开始命令中我输入了 play.evolutions.db.default.autoApply
没有运气,任何人都可以帮助如何让竹子相信进化可以保留我的激活器运行ning?
我的ci-开始-all.sh:
#!/bin/sh
set -e
. ./ci/ci-set-env.sh
./ci/play-start.sh
set +e
还有我的戏-start.sh :
#!/bin/sh
set -e
echo
echo '****** PLAY START *******'
echo
nohup ./target/universal/stage/bin/webapp -Dplay.evolutions.db.default.autoApply=true -Dhttp.port=$PLAY_PORT -Dconfig.file=conf/cloud.conf &>play.out &
sleep 10
#look for process listening to port TODO: replace with wget and a url
pid=`lsof -Pi tcp:$PLAY_PORT | grep LISTEN | awk '{print }'`
if [ $pid > 0 ];
then
echo [success] Play! started
else
echo ERROR: Play! did not start successfully
#output logfile
cat play.out
exit 1
fi
set +e
我的日志文件:
ERROR: Play! did not start successfully
11-Nov-2015 11:23:20 Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
11-Nov-2015 11:23:20 2015-11-11 11:23:12 +0200 1105 INFO application - Creating Pool for datasource 'default'
11-Nov-2015 11:23:20 2015-11-11 11:23:13 +0200 2166 INFO play.api.db.DefaultDBApi - Database [default] connected at jdbc:mysql://localhost/timesheets_dev?zeroDateTimeBehavior=convertToNull
11-Nov-2015 11:23:20 2015-11-11 11:23:14 +0200 2889 WARN p.a.d.e.ApplicationEvolutions - Your production database [default] needs evolutions, including downs!
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 # !!! WARNING! This script contains DOWNS evolutions that are likely destructives
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 # --- Rev:3,Downs - 9cadf53
11-Nov-2015 11:23:20 ALTER TABLE ACCOUNTS DROP users_count;
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 # --- Rev:3,Ups - 79049fc
11-Nov-2015 11:23:20 ALTER TABLE ACCOUNTS ADD users_count int DEFAULT 0 NULL;
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 UPDATE ACCOUNTS a SET users_count = (SELECT COUNT(*) FROM USERS u WHERE u.account_id = a.id and u.is_active = true);
11-Nov-2015 11:23:20
11-Nov-2015 11:23:20 2015-11-11 11:23:14 +0200 2896 WARN p.a.d.e.ApplicationEvolutions - Run with -Dplay.evolutions.db.default.autoApply=true and -Dplay.evolutions.db.default.autoApplyDowns=true if you want to run them automatically, including downs (be careful, especially if your down evolutions drop existing data)
11-Nov-2015 11:23:20 Oops, cannot start the server.
11-Nov-2015 11:23:20 @6o4mnmhf7: Database 'default' needs evolution!
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions$$anonfun$play$api$db$evolutions$ApplicationEvolutions$$runEvolutions.apply$mcV$sp(ApplicationEvolutions.scala:68)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.withLock(ApplicationEvolutions.scala:98)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.play$api$db$evolutions$ApplicationEvolutions$$runEvolutions(ApplicationEvolutions.scala:49)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions$$anonfun$start.apply(ApplicationEvolutions.scala:42)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions$$anonfun$start.apply(ApplicationEvolutions.scala:42)
11-Nov-2015 11:23:20 at scala.collection.immutable.List.foreach(List.scala:381)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.start(ApplicationEvolutions.scala:42)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutions.<init>(ApplicationEvolutions.scala:149)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutionsProvider.get$lzycompute(EvolutionsModule.scala:53)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:53)
11-Nov-2015 11:23:20 at play.api.db.evolutions.ApplicationEvolutionsProvider.get(EvolutionsModule.scala:44)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
11-Nov-2015 11:23:20 at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
11-Nov-2015 11:23:20 at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderToInternalFactoryAdapter.call(ProviderToInternalFactoryAdapter.java:46)
11-Nov-2015 11:23:20 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
11-Nov-2015 11:23:20 at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
11-Nov-2015 11:23:20 at com.google.inject.internal.SingletonScope.get(SingletonScope.java:145)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.call(InternalInjectorCreator.java:205)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.call(InternalInjectorCreator.java:199)
11-Nov-2015 11:23:20 at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
11-Nov-2015 11:23:20 at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
11-Nov-2015 11:23:20 at com.google.inject.Guice.createInjector(Guice.java:96)
11-Nov-2015 11:23:20 at com.google.inject.Guice.createInjector(Guice.java:73)
11-Nov-2015 11:23:20 at com.google.inject.Guice.createInjector(Guice.java:62)
11-Nov-2015 11:23:20 at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
11-Nov-2015 11:23:20 at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
11-Nov-2015 11:23:20 at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
11-Nov-2015 11:23:20 at play.core.server.ProdServerStart$.start(ProdServerStart.scala:52)
11-Nov-2015 11:23:20 at play.core.server.ProdServerStart$.main(ProdServerStart.scala:27)
11-Nov-2015 11:23:20 at play.core.server.ProdServerStart.main(ProdServerStart.scala)
11-Nov-2015 11:23:20 Failing task since return code of [./ci/ci-start-all.sh] was 1 while expected 0
11-Nov-2015 11:23:20 Finished task 'CI Start All' with result: Failed
11-Nov-2015 11:23:20 Running post build plugin 'npm Cache Cleanup'
11-Nov-2015 11:23:20 Running post build plugin 'NCover Results Collector'
11-Nov-2015 11:23:20 Running post build plugin 'Clover Results Collector'
11-Nov-2015 11:23:20 Running post build plugin 'Artifact Copier'
11-Nov-2015 11:23:20 Publishing an artifact: XXX
11-Nov-2015 11:24:03 Finished publishing of artifact Shared artifact: [XXX], pattern: [**/*] in 43s
11-Nov-2015 11:24:03 Finalising the build...
11-Nov-2015 11:24:03 Stopping timer.
11-Nov-2015 11:24:03 Build XXX-173 completed.
11-Nov-2015 11:24:03 Running on server: post build plugin 'NCover Results Collector'
11-Nov-2015 11:24:03 Running on server: post build plugin 'Clover Delta Calculator'
11-Nov-2015 11:24:03 Running on server: post build plugin 'Maven Dependencies Postprocessor'
11-Nov-2015 11:24:03 Running on server: post build plugin 'Build Hanging Detection Configuration'
11-Nov-2015 11:24:03 All post build plugins have finished
11-Nov-2015 11:24:03 Generating build results summary...
11-Nov-2015 11:24:07 Saving build results to disk...
11-Nov-2015 11:24:07 Indexing build results...
11-Nov-2015 11:24:07 Finished building XXX-173
有时当它是一种破坏性的进化时它会停止,我只是在 application.conf
中添加了以下几行以使其成为 运行 你需要从配置中设置值并强制进化但要小心,你不需要丢失你的数据,如果你只是在开发阶段并且它可以这样做,否则保持 play.evolutions.autoApplyDowns
为假,或者根本不把它保持默认值(这对于生产是假的)
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=true
# You can disable evolutions for a specific datasource if necessary
play.evolutions.db.default.enabled=true
# this is safe to use if there is no "DOWNS" otherwise it will fail to start
play.evolutions.autoApply = true
# BECAREFUL ITS DANGROUS DON'T USE IN PRODUCTION
play.evolutions.autoApplyDowns = true