英文:
When is Procfile actually needed in Heroku
问题
我已安装了Java、Git、Heroku CLI,并且已经设置了Heroku账号。
我尝试遵循下面的教程:
当我部署应用时,它实际上按预期工作。问题是,我尝试删除了Procfile,因为我在某个地方读到它实际上是不需要的,这次在没有该文件的情况下也正常工作。
但是,当我添加了自己的Java Maven项目(非Web应用程序)并将其推送到我在命令行上创建的Heroku应用时,我得到了一个确认,即我的应用已成功部署。
但是,当我通过heroku open命令在新浏览器中打开应用时,我收到了这个错误:
所以我运行了这个heroku logs --tail命令来检查错误,输出的末尾我看到了这个:
> 2020-04-07T15:38:37.788790+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/"
所以我的猜想是我需要为应用程序添加一个Procfile,于是我在根目录下创建了一个,并添加了以下行:
> web:java -jar target/mystuff-0.0.1-SNAPSHOT.jar
但是它仍然没有工作。所以我猜我需要扩展我的应用,因此运行了heroku ps:scale web=1,但是然后我得到了错误消息Couldn't find that process type (web)。
是什么导致了这个问题?我有点困惑了。
任何建议将不胜感激。
英文:
I have installed Java, Git, Heroku CLI and have a Heroku account as well setup.
I have tried to follow this tutorial below:
And when I deploy the app it actually works just as expected. The thing is that I tried to
remove the Procfile since I read somewhere that its actually not needed and this time it
also worked well without that file.
But when I added my own Java maven project (non-web application) and pushed it to my Heroku app that I created on commandline I got a confirmation that my app is successfully deployed.
But once I opened the app through heroku open command in a new browser I get this error:
So I run this heroku logs --tail command to check errors and at the end of the output I see
this:
> 2020-04-07T15:38:37.788790+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/"
So my guess is that I need to add a Procfile for the application so what I did was to create one in the root directory and add following line to it:
> web:java -jar target/mystuff-0.0.1-SNAPSHOT.jar
So it still didnt work. So I guessed I needed to scale up my application so ran
heroku ps:scale web=1 but then I get the error message Couldn't find that process type (web).
Whats causing this thing to happen? Im getting a bit confused here
Any advice would be highly appreciated
专注分享java语言的经验与见解,让所有开发者获益!
评论