Add healthcheck and do rollback if not working

main
midudev 3 years ago
parent fccedaa0df
commit 41f8589b64

@ -35,3 +35,5 @@ jobs:
heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: ${{secrets.HEROKU_APP}} heroku_app_name: ${{secrets.HEROKU_APP}}
heroku_email: ${{secrets.HEROKU_API_EMAIL}} heroku_email: ${{secrets.HEROKU_API_EMAIL}}
healthcheck: "https://${{secrets.HEROKU_APP}}/health"
rollbackonhealthcheckfailed: true

@ -1,9 +1,18 @@
const express = require('express') const express = require('express')
const app = express() const app = express()
const { version } = require('./package.json')
// Heroku dynamically sets a port // Heroku dynamically sets a port
const PORT = process.env.PORT || 5000 const PORT = process.env.PORT || 5000
app.get('/health', (req, res) => {
res.send('ok')
})
app.get('/version', (req, res) => {
res.send(version)
})
app.use(express.static('dist')) app.use(express.static('dist'))
app.listen(PORT, () => { app.listen(PORT, () => {

@ -4,9 +4,9 @@
"description": "Full Stack Open", "description": "Full Stack Open",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {
"start": "webpack-dev-server --open --mode development", "dev": "webpack-dev-server --open --mode development",
"start-test": "NODE_ENV=test node app.js", "start-test": "NODE_ENV=test node app.js",
"start-prod": "node app.js", "start": "node app.js",
"test": "jest", "test": "jest",
"eslint": "eslint './**/*.{js,jsx}'", "eslint": "eslint './**/*.{js,jsx}'",
"build": "webpack --mode production", "build": "webpack --mode production",

Loading…
Cancel
Save