Last active
June 30, 2021 17:23
-
-
Save fitzgeraldsteele/c182178ceec4c2c2b6dd130fc101c44e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
package_upgrade: true | |
packages: | |
- nginx | |
- nodejs | |
- npm | |
write_files: | |
- owner: www-data:www-data | |
path: /etc/nginx/sites-available/default | |
content: | | |
server { | |
listen 80; | |
location / { | |
proxy_pass http://localhost:3000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection keep-alive; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} | |
- owner: azureuser:azureuser | |
path: /home/azureuser/myapp/index.js | |
content: | | |
var express = require('express') | |
var app = express() | |
var os = require('os') | |
var dayjs = require('dayjs'); | |
app.get('/health', function (req, res) { | |
var today = dayjs().format('dddd') // Return day of week in Sunday - Saturday format | |
if (today.slice(-1) == 'y') { // If the day of the week ends in y, the instance is healthy. This is obviously a silly example; your code can do whatever | |
res.status(200).send('Thank you for checking in. It has been a CRAZY year, and I am just taking it one day at a time. How you you?') | |
} else { | |
res.status(500).send('Something went terribly wrong') | |
} | |
}) | |
app.listen(3000, function () { | |
console.log('Hello world app listening on port 3000!') | |
}) | |
runcmd: | |
- service nginx restart | |
- cd "/home/azureuser/myapp" | |
- npm init | |
- npm install express -y | |
- npm install nodemon -y | |
- npm install ejs -y | |
- npm install dayjs -y | |
- nodejs index.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment