秘匿情報の環境変数化
本番とbetaで application.conf を分けて、リポジトリのブランチを分けて...とするのが面倒。環境変数化して気にしないようにしたい。
heroku の場合、デフォルトで、
DATABASE_URL に DB の設定が入っているので、コレを使う。
PLAY_SECRET_KEY は beta では設定しないことにする
設定する値
IMAGE_BASE_URL
GOOGLE_KEY
GOOGLE_CX
参考
Production Configuration - 2.8.x
You can also reference environment variables from your application.conf file:
application.conf から環境変数を参照することができる
code:scala
my.key = defaultvalue
my.key = ${?MY_KEY_ENV}
Here, the override field my.key = ${?MY_KEY_ENV} simply vanishes if there’s no value for MY_KEY_ENV, but if you set an environment variable MY_KEY_ENV for example, it would be used.
環境変数が設定されていない場合はなかったことになる
エラ
PLAY_SECRET_KEY を環境変数に設定していないから?
code:sh
2020-09-25T08:23:33.885833+00:00 appweb.1: Oops, cannot start the server. 2020-09-25T08:23:33.886434+00:00 appweb.1: Configuration error: Configuration error[ 2020-09-25T08:23:33.886436+00:00 appweb.1: The application secret has not been set, and we are in prod mode. Your application is not secure. 2020-09-25T08:23:33.886469+00:00 appweb.1: ] 2020-09-25T08:23:33.886590+00:00 appweb.1: at play.api.Configuration$.configError(Configuration.scala:171) 2020-09-25T08:23:33.886673+00:00 appweb.1: at play.api.Configuration.reportError(Configuration.scala:1018) 2020-09-25T08:23:33.886744+00:00 appweb.1: at play.api.http.HttpConfiguration$.getSecretConfiguration(HttpConfiguration.scala:295) 2020-09-25T08:23:33.886955+00:00 appweb.1: at play.api.http.HttpConfiguration$.fromConfiguration(HttpConfiguration.scala:280) 2020-09-25T08:23:33.886956+00:00 appweb.1: at play.api.http.HttpConfiguration$HttpConfigurationProvider.get$lzycompute(HttpConfiguration.scala:374) 2020-09-25T08:23:33.886961+00:00 appweb.1: at play.api.http.HttpConfiguration$HttpConfigurationProvider.get(HttpConfiguration.scala:374) 2020-09-25T08:23:33.887042+00:00 appweb.1: at play.api.http.HttpConfiguration$HttpConfigurationProvider.get(HttpConfiguration.scala:372) 2020-09-25T08:23:33.887112+00:00 appweb.1: at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:85) 2020-09-25T08:23:33.887207+00:00 appweb.1: at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:77) 2020-09-25T08:23:33.887280+00:00 appweb.1: at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:59) 2020-09-25T08:23:33.887344+00:00 appweb.1: at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:61) 2020-09-25T08:23:33.887426+00:00 appweb.1: at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42) 2020-09-25T08:23:33.887497+00:00 appweb.1: at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65) 2020-09-25T08:23:33.887563+00:00 appweb.1: at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) 2020-09-25T08:23:33.887636+00:00 appweb.1: at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) 2020-09-25T08:23:33.887721+00:00 appweb.1: at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) 2020-09-25T08:23:33.887782+00:00 appweb.1: at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) 2020-09-25T08:23:33.887904+00:00 appweb.1: at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168) 2020-09-25T08:23:33.887964+00:00 appweb.1: at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39) 2020-09-25T08:23:33.888053+00:00 appweb.1: at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:60) 2020-09-25T08:23:33.888114+00:00 appweb.1: at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42) 2020-09-25T08:23:33.888195+00:00 appweb.1: at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65) 2020-09-25T08:23:33.888253+00:00 appweb.1: at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) 2020-09-25T08:23:33.888340+00:00 appweb.1: at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) 2020-09-25T08:23:33.888425+00:00 appweb.1: at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) 2020-09-25T08:23:33.888486+00:00 appweb.1: at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62) 2020-09-25T08:23:33.888563+00:00 appweb.1: at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42) 2020-09-25T08:23:33.888638+00:00 appweb.1: at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65) 2020-09-25T08:23:33.888713+00:00 appweb.1: at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113) 2020-09-25T08:23:33.888803+00:00 appweb.1: at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91) 2020-09-25T08:23:33.888879+00:00 appweb.1: at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306) 2020-09-25T08:23:33.888970+00:00 appweb.1: at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) 2020-09-25T08:23:33.889028+00:00 appweb.1: at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168) 2020-09-25T08:23:33.889101+00:00 appweb.1: at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39) 2020-09-25T08:23:33.889178+00:00 appweb.1: at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62) 2020-09-25T08:23:33.889262+00:00 appweb.1: at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:211) 2020-09-25T08:23:33.889341+00:00 appweb.1: at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:182) 2020-09-25T08:23:33.889413+00:00 appweb.1: at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109) 2020-09-25T08:23:33.889538+00:00 appweb.1: at com.google.inject.Guice.createInjector(Guice.java:87) 2020-09-25T08:23:33.889620+00:00 appweb.1: at com.google.inject.Guice.createInjector(Guice.java:78) 2020-09-25T08:23:33.889720+00:00 appweb.1: at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:201) 2020-09-25T08:23:33.889767+00:00 appweb.1: at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:156) 2020-09-25T08:23:33.889850+00:00 appweb.1: at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:22) 2020-09-25T08:23:33.889909+00:00 appweb.1: at play.core.server.ProdServerStart$.start(ProdServerStart.scala:59) 2020-09-25T08:23:33.889986+00:00 appweb.1: at play.core.server.ProdServerStart$.main(ProdServerStart.scala:31) 2020-09-25T08:23:33.890059+00:00 appweb.1: at play.core.server.ProdServerStart.main(ProdServerStart.scala) 2020-09-25T08:23:34.032938+00:00 herokuweb.1: Process exited with status 255 2020-09-25T08:23:34.085998+00:00 herokuweb.1: State changed from starting to crashed なんか別の謎のエラーが
secret は changeme じゃなければ動いていそう
db接続できていない?
jdbc の URL としておかしい値が設定されているっぽい
code:sh
2020-09-25T09:29:18.343553+00:00 appweb.1: 2020-09-25T09:29:18.343557+00:00 appweb.1: at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:347) 2020-09-25T09:29:18.343558+00:00 appweb.1: at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:267) 2020-09-25T09:29:18.343558+00:00 appweb.1: at play.core.server.AkkaHttpServer$$anonfun$3.applyOrElse(AkkaHttpServer.scala:448) 2020-09-25T09:29:18.343559+00:00 appweb.1: at play.core.server.AkkaHttpServer$$anonfun$3.applyOrElse(AkkaHttpServer.scala:446) 2020-09-25T09:29:18.343559+00:00 appweb.1: at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346) 2020-09-25T09:29:18.343560+00:00 appweb.1: at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345) 2020-09-25T09:29:18.343560+00:00 appweb.1: at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36) 2020-09-25T09:29:18.343561+00:00 appweb.1: at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55) 2020-09-25T09:29:18.343561+00:00 appweb.1: at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:92) 2020-09-25T09:29:18.343561+00:00 appweb.1: at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:92) 2020-09-25T09:29:18.343562+00:00 appweb.1: at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:92) 2020-09-25T09:29:18.343562+00:00 appweb.1: at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72) 2020-09-25T09:29:18.343563+00:00 appweb.1: at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91) 2020-09-25T09:29:18.343563+00:00 appweb.1: at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41) 2020-09-25T09:29:18.343563+00:00 appweb.1: at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:49) 2020-09-25T09:29:18.343564+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 2020-09-25T09:29:18.343564+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) 2020-09-25T09:29:18.343565+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 2020-09-25T09:29:18.343565+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) 2020-09-25T09:29:18.343567+00:00 appweb.1: Caused by: java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, postgres://xxxxx/yyyyy 2020-09-25T09:29:18.343567+00:00 appweb.1: at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:108) 2020-09-25T09:29:18.343568+00:00 appweb.1: at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:336) 2020-09-25T09:29:18.343569+00:00 appweb.1: at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:109) 2020-09-25T09:29:18.343569+00:00 appweb.1: at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:108) 2020-09-25T09:29:18.343570+00:00 appweb.1: at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81) 2020-09-25T09:29:18.343570+00:00 appweb.1: at slick.jdbc.hikaricp.HikariCPJdbcDataSource$.forConfig(HikariCPJdbcDataSource.scala:92) 2020-09-25T09:29:18.343571+00:00 appweb.1: at slick.jdbc.hikaricp.HikariCPJdbcDataSource$.forConfig(HikariCPJdbcDataSource.scala:21) 2020-09-25T09:29:18.343571+00:00 appweb.1: at slick.jdbc.JdbcDataSource$.forConfig(JdbcDataSource.scala:47) 2020-09-25T09:29:18.343572+00:00 appweb.1: at slick.jdbc.JdbcBackend$DatabaseFactoryDef$class.forConfig(JdbcBackend.scala:341) 2020-09-25T09:29:18.343572+00:00 appweb.1: at slick.jdbc.JdbcBackend$$anon$3.forConfig(JdbcBackend.scala:32) 2020-09-25T09:29:18.343572+00:00 appweb.1: at slick.jdbc.JdbcBackend$class.createDatabase(JdbcBackend.scala:35) 2020-09-25T09:29:18.343573+00:00 appweb.1: at slick.jdbc.JdbcBackend$.createDatabase(JdbcBackend.scala:572) 2020-09-25T09:29:18.343573+00:00 appweb.1: at slick.jdbc.JdbcBackend$.createDatabase(JdbcBackend.scala:572) 2020-09-25T09:29:18.343573+00:00 appweb.1: at slick.basic.DatabaseConfig$$anon$1.db$lzycompute(DatabaseConfig.scala:103) 2020-09-25T09:29:18.343574+00:00 appweb.1: at slick.basic.DatabaseConfig$$anon$1.db(DatabaseConfig.scala:102) 2020-09-25T09:29:18.343574+00:00 appweb.1: at play.api.db.slick.HasDatabaseConfig$class.db(DatabaseConfigProvider.scala:157) 2020-09-25T09:29:18.343574+00:00 appweb.1: at database.ImageDatabase.db(ImageDatabase.scala:26) 2020-09-25T09:29:18.343575+00:00 appweb.1: at database.ImageDatabase.recentIds(ImageDatabase.scala:41) 2020-09-25T09:29:18.343575+00:00 appweb.1: at controllers.ImageController$$anonfun$recent$1.apply(ImageController.scala:21) 2020-09-25T09:29:18.343576+00:00 appweb.1: at controllers.ImageController$$anonfun$recent$1.apply(ImageController.scala:20) 2020-09-25T09:29:18.343576+00:00 appweb.1: at play.api.mvc.ActionBuilderImpl.invokeBlock(Action.scala:489) 2020-09-25T09:29:18.343576+00:00 appweb.1: at play.api.mvc.ActionBuilderImpl.invokeBlock(Action.scala:487) 2020-09-25T09:29:18.343577+00:00 appweb.1: at play.api.mvc.ActionBuilder$$anon$2.apply(Action.scala:426) 2020-09-25T09:29:18.343577+00:00 appweb.1: at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:98) 2020-09-25T09:29:18.343577+00:00 appweb.1: at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:91) 2020-09-25T09:29:18.343585+00:00 appweb.1: at play.api.libs.streams.StrictAccumulator$$anonfun$mapFuture$2$$anonfun$1.apply(Accumulator.scala:184) 2020-09-25T09:29:18.343585+00:00 appweb.1: at play.api.libs.streams.StrictAccumulator$$anonfun$mapFuture$2$$anonfun$1.apply(Accumulator.scala:184) 2020-09-25T09:29:18.343585+00:00 appweb.1: at scala.util.Try$.apply(Try.scala:192) 2020-09-25T09:29:18.343586+00:00 appweb.1: at play.api.libs.streams.StrictAccumulator$$anonfun$mapFuture$2.apply(Accumulator.scala:184) 2020-09-25T09:29:18.343586+00:00 appweb.1: at play.api.libs.streams.StrictAccumulator$$anonfun$mapFuture$2.apply(Accumulator.scala:180) 2020-09-25T09:29:18.343587+00:00 appweb.1: at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:52) 2020-09-25T09:29:18.343587+00:00 appweb.1: at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:52) 2020-09-25T09:29:18.343588+00:00 appweb.1: at play.api.libs.streams.StrictAccumulator.run(Accumulator.scala:219) 2020-09-25T09:29:18.343588+00:00 appweb.1: at play.core.server.AkkaHttpServer$$anonfun$16.apply(AkkaHttpServer.scala:441) 2020-09-25T09:29:18.343588+00:00 appweb.1: at play.core.server.AkkaHttpServer$$anonfun$16.apply(AkkaHttpServer.scala:439) 2020-09-25T09:29:18.343590+00:00 appweb.1: at akka.http.scaladsl.util.FastFuture$.akka$http$scaladsl$util$FastFuture$$strictTransform$1(FastFuture.scala:41) 2020-09-25T09:29:18.343590+00:00 appweb.1: at akka.http.scaladsl.util.FastFuture$$anonfun$transformWith$extension1$1.apply(FastFuture.scala:51) 2020-09-25T09:29:18.343591+00:00 appweb.1: at akka.http.scaladsl.util.FastFuture$$anonfun$transformWith$extension1$1.apply(FastFuture.scala:50) 2020-09-25T09:29:18.343591+00:00 appweb.1: ... 13 common frames omitted 続いて画像生成時のエラー
code:sh
020-09-25T11:16:49.399757+00:00 appweb.1: [[31merror0m - akka.actor.OneForOneStrategy - java.io.FileNotFoundException: convert 2020-09-25T11:16:49.399785+00:00 appweb.1: org.im4java.core.CommandException: java.io.FileNotFoundException: convert 2020-09-25T11:16:49.399787+00:00 appweb.1: at org.im4java.core.ImageCommand.run(ImageCommand.java:219) 2020-09-25T11:16:49.399787+00:00 appweb.1: at command.ImageMagick.execute(ImageMagick.scala:50) 2020-09-25T11:16:49.399787+00:00 appweb.1: at command.ImageMagick.convert(ImageMagick.scala:44) 2020-09-25T11:16:49.399788+00:00 appweb.1: at actor.ImageActor$$anonfun$receive$1.applyOrElse(ImageActor.scala:38) 2020-09-25T11:16:49.399788+00:00 appweb.1: at akka.actor.Actor$class.aroundReceive(Actor.scala:539) 2020-09-25T11:16:49.399789+00:00 appweb.1: at actor.ImageActor.aroundReceive(ImageActor.scala:19) 2020-09-25T11:16:49.399789+00:00 appweb.1: at akka.actor.ActorCell.receiveMessage(ActorCell.scala:612) 2020-09-25T11:16:49.399789+00:00 appweb.1: at akka.actor.ActorCell.invoke(ActorCell.scala:581) 2020-09-25T11:16:49.399789+00:00 appweb.1: at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268) 2020-09-25T11:16:49.399790+00:00 appweb.1: at akka.dispatch.Mailbox.run(Mailbox.scala:229) 2020-09-25T11:16:49.399790+00:00 appweb.1: at akka.dispatch.Mailbox.exec(Mailbox.scala:241) 2020-09-25T11:16:49.399790+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 2020-09-25T11:16:49.399791+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) 2020-09-25T11:16:49.399791+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 2020-09-25T11:16:49.399791+00:00 appweb.1: at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) 2020-09-25T11:16:49.399792+00:00 appweb.1: Caused by: java.io.FileNotFoundException: convert 2020-09-25T11:16:49.399792+00:00 appweb.1: at org.im4java.process.ProcessStarter.searchForCmd(ProcessStarter.java:661) 2020-09-25T11:16:49.399792+00:00 appweb.1: at org.im4java.process.ProcessStarter.startProcess(ProcessStarter.java:399) 2020-09-25T11:16:49.399793+00:00 appweb.1: at org.im4java.process.ProcessStarter.run(ProcessStarter.java:312) 2020-09-25T11:16:49.399793+00:00 appweb.1: at org.im4java.core.ImageCommand.run(ImageCommand.java:215) 2020-09-25T11:16:49.399794+00:00 appweb.1: ... 14 common frames omitted