FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docs/script/ping-staging-apps.js at main · capablemonkey/docs · GitHub
capablemonkey
/
docs
Public
forked from
github/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docs
/
script
/
ping-staging-apps.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
39 lines (31 loc) · 1017 Bytes
Breadcrumbs
docs
/
script
/
ping-staging-apps.js
Copy path
File metadata and controls
executable file
·
39 lines (31 loc) · 1017 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
// [start-readme]
//
// This script finds all Heroku staging apps and pings them to make sure they're always "warmed" and responsive to requests.
//
// [end-readme]
require
(
'dotenv'
)
.
config
(
)
const
assert
=
require
(
'assert'
)
const
got
=
require
(
'got'
)
assert
(
process
.
env
.
HEROKU_API_TOKEN
)
const
{
chain
}
=
require
(
'lodash'
)
const
chalk
=
require
(
'chalk'
)
const
Heroku
=
require
(
'heroku-client'
)
const
heroku
=
new
Heroku
(
{
token
:
process
.
env
.
HEROKU_API_TOKEN
}
)
main
(
)
async
function
main
(
)
{
const
apps
=
chain
(
await
heroku
.
get
(
'/apps'
)
)
.
orderBy
(
'name'
)
.
value
(
)
async
function
ping
(
app
)
{
// ?warmup param has no effect but makes it easier to find these requests in the logs
const
url
=
`https://
${
app
.
name
}
.herokuapp.com/en?warmup`
try
{
const
response
=
await
got
(
url
)
console
.
log
(
chalk
.
green
(
url
,
response
.
statusCode
)
)
}
catch
(
error
)
{
console
.
log
(
chalk
.
red
(
url
,
error
.
response
.
statusCode
)
)
}
}
Promise
.
all
(
apps
.
map
(
ping
)
)
}
Back
|
FazBrowse Home
|
New Git URL