2016-03-06 273 views
3

我正在嘗試將我的Pl​​ay應用程序部署到Heroku。部署到Heroku時失敗

可惜的是,我得到這個問題:

2016-03-06T14:19:45.939373+00:00 heroku[web.1]: State changed from starting to crashed 
2016-03-06T14:19:45.918504+00:00 heroku[web.1]: Process exited with status 255 
2016-03-06T14:49:45.477844+00:00 heroku[web.1]: State changed from crashed to starting 
2016-03-06T14:49:49.783812+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/todolistscala -Dhttp.port=12681` 
2016-03-06T14:49:51.431641+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them. 
2016-03-06T14:49:51.599056+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8 
2016-03-06T14:49:54.014919+00:00 app[web.1]: [[37minfo[0m] application - Creating Pool for datasource 'default' 
2016-03-06T14:49:54.492047+00:00 app[web.1]: [[37minfo[0m] p.a.d.DefaultDBApi - Database [default] connected at jdbc:h2:mem:play 
2016-03-06T14:49:57.727928+00:00 app[web.1]: [[33mwarn[0m] application - application.conf @ file:/app/target/universal/stage/conf/application.conf: 348: applyEvolutions.default is deprecated, use play.evolutions.db.default.autoApply instead 
2016-03-06T14:49:58.246865+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure. 
2016-03-06T14:49:58.247105+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret 
2016-03-06T14:49:58.258404+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure. 
2016-03-06T14:49:58.258431+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret 
2016-03-06T14:49:58.258933+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure. 
2016-03-06T14:49:58.259062+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret 
2016-03-06T14:49:58.293455+00:00 app[web.1]: [[37minfo[0m] application - ApplicationTimer demo: Starting application at 2016-03-06T14:49:58.259Z. 
2016-03-06T14:49:58.294643+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure. 
2016-03-06T14:49:58.294826+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret 
2016-03-06T14:49:58.297164+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure. 
2016-03-06T14:49:58.297222+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret 
2016-03-06T14:49:58.297271+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - The application secret has not been set, and we are in prod mode. Your application is not secure. 
2016-03-06T14:49:58.297976+00:00 app[web.1]: [[31merror[0m] p.a.l.c.CryptoConfigParser - To set the application secret, please read http://playframework.com/documentation/latest/ApplicationSecret 
2016-03-06T14:49:58.303328+00:00 app[web.1]: Oops, cannot start the server. 
2016-03-06T14:49:58.305408+00:00 app[web.1]: @6pba2k59a: Configuration error 
2016-03-06T14:49:58.305742+00:00 app[web.1]: at play.api.libs.crypto.CryptoConfigParser.get$lzycompute(Crypto.scala:498) 
2016-03-06T14:49:58.305830+00:00 app[web.1]: at play.api.libs.crypto.CryptoConfigParser.get(Crypto.scala:465) 
2016-03-06T14:49:58.305890+00:00 app[web.1]: at play.api.libs.crypto.CryptoConfigParser.get(Crypto.scala:463) 
2016-03-06T14:49:58.305953+00:00 app[web.1]: at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81) 
2016-03-06T14:49:58.306059+00:00 app[web.1]: at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72) 

由於沒有涉及Application Secret一個錯誤,我這樣說的:https://www.playframework.com/documentation/2.5.x/ApplicationSecret。但是,我不明白如何將密鑰發送到服務器環境而不在本地計算機上。

但無論如何,我不確定沒有Application Secret是問題的真正原因,因爲服務器無法啓動(即使我沒有Application Secret,我也會認爲服務器可以啓動) 。

這種故障的原因是什麼?

+0

「application.conf」的內容是什麼? – codefinger

回答

3

您應該將應用程序密鑰設置爲Heroku上的環境變量。這樣,它只能在應用程序環境中使用,並且如果需要,可以輕鬆更改而無需重新部署。

您可以將標記添加到您的Procfile

web: target/universal/stage/bin/todolistscala \ 
-Dhttp.port=12681 \ 
-Dplay.crypto.secret=${APPLICATION_SECRET} 

以上是一個更好的可視化,但Procfile不會與每個進程多個行工作。它應該是這樣的:

web: target/universal/stage/bin/todolistscala -Dhttp.port=12681 -Dplay.crypto.secret=${APPLICATION_SECRET} 

然後你設置環境變量APPLICATION_SECRET。您可以從Heroku的Web界面做這一點,或使用Heroku的工具區:

heroku config:set APPLICATION_SECRET="thisisthesecretpleasechangeit" -a your-app-name 

一般來說,所有的重要憑據(數據庫,緩存服務器,API密鑰)應當被存儲的應用環境中的這種方式。

+0

我創建了'Procfile',設置了環境變量並提交了'Procfile'。但是,當我推送時,我仍然遇到同樣的錯誤。 – octavian

+0

你真的使用Play 2.5或2.4嗎? 2.3或更早版本使用'application.secret'而不是'play.crypto.secret'。 –

+1

現在我想起來了,'Procfile'煩人的必須是一行,所以如果你複製/粘貼了我的東西,它會忽略其他行。 –