创建您的免费 Redis Cloud 账户。 点击此链接创建 Redis Cloud 订阅和数据库,如下所示:
保存数据库端点 URL 和密码供以后参考。
如果您是第一次使用 Heroku,请通过此链接创建新的 Heroku 账户: 通过此链接
brew install heroku
heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA
Logging in... done
Logged in as your_email_address
本次演示我们将使用一个 示例速率限制应用程序
git clone https://github.com/redis-developer/basic-rate-limiting-demo-java
heroku create
Creating app... done, ⬢ hidden-woodland-03996
https://hidden-woodland-03996.herokuapp.com/ | https://git.heroku.com/hidden-woodland-03996.git
转到 Heroku 仪表盘,点击“Settings”,在 Config Vars 下设置 REDIS_ENDPOINT_URI
和 REDIS_PASSWORD
。请参考步骤 1。
现在您拥有一个功能正常的 Git 仓库,其中包含一个简单的应用程序以及一个 package.json 文件,该文件由 Node 的依赖管理器使用。
Heroku 会为您的应用程序生成一个随机名称(在本例中为 hidden-woodland-03996),或者您可以传递参数来指定您自己的应用程序名称。现在部署您的代码
$ git push heroku
remote: BUILD SUCCESSFUL in 1m 5s
remote: 12 actionable tasks: 12 executed
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 298.9M
remote: -----> Launching...
remote: Released v3
remote: https://hidden-woodland-03996.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/hidden-woodland-03996.git
* [new branch] master -> master
打开 https://hidden-woodland-03996.herokuapp.com/ 查看您的应用程序