This repository has been archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24f6d3c
commit ce94b18
Showing
12 changed files
with
199 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
## https://rapid-prereview.azurewebsites.net/ | ||
|
||
## See https://docs.microsoft.com/en-us/azure/app-service/deploy-zip | ||
|
||
zip -r app.zip *.json *.js dist/* src/* public/* views/* scripts/* test/* | ||
|
||
## See https://docs.microsoft.com/en-us/azure/app-service/containers/configure-language-nodejs | ||
|
||
## TODO env variables: az webapp config appsettings set --name <app-name> --resource-group myResourceGroup --settings MONGODB_URI="mongodb://<cosmosdb-name>:<primary-master-key>@<cosmosdb-name>.documents.azure.com:10250/mean?ssl=true" | ||
|
||
az webapp config appsettings set --resource-group "rapid-prereview" --name "rapid-prereview" --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true | ||
|
||
az webapp config set --resource-group "rapid-prereview" --name "rapid-prereview" --startup-file "npm run start:prod" | ||
|
||
az webapp deployment source config-zip --resource-group "rapid-prereview" --name "rapid-prereview" --src app.zip | ||
|
||
rm app.zip |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
## https://rapid-prereview-service.azurewebsites.net/ | ||
|
||
## See https://docs.microsoft.com/en-us/azure/app-service/deploy-zip | ||
|
||
zip -r service.zip *.json *.js dist/* src/* public/* views/* scripts/* test/* | ||
|
||
## See https://docs.microsoft.com/en-us/azure/app-service/containers/configure-language-nodejs | ||
|
||
az webapp config appsettings set --resource-group "rapid-prereview" --name "rapid-prereview-service" --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true | ||
|
||
az webapp config set --resource-group "rapid-prereview" --name "rapid-prereview-service" --startup-file "npm run start:prod" | ||
|
||
az webapp deployment source config-zip --resource-group "rapid-prereview" --name "rapid-prereview-service" --src service.zip | ||
|
||
rm service.zip |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
az webapp log config --name "rapid-prereview" --resource-group "rapid-prereview" --docker-container-logging filesystem | ||
az webapp log tail --name "rapid-prereview" --resource-group "rapid-prereview" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
az webapp log config --name "rapid-prereview-service" --resource-group "rapid-prereview" --docker-container-logging filesystem | ||
az webapp log tail --name "rapid-prereview-service" --resource-group "rapid-prereview" |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import http from 'http'; | ||
import express from 'express'; | ||
import webpack from 'webpack'; | ||
import webpackDevMiddleware from 'webpack-dev-middleware'; | ||
import webpackHotMiddleware from 'webpack-hot-middleware'; | ||
import webpackConfig from '../webpack.config'; | ||
import DB from '../src/db/db'; | ||
import Feed from '../src/db/feed'; | ||
import { rapid, assets } from './index'; | ||
import { | ||
setIntervalAsync, | ||
clearIntervalAsync | ||
} from './utils/set-interval-async'; | ||
|
||
const compiler = webpack(webpackConfig); | ||
|
||
const config = { | ||
disableSsr: true | ||
}; | ||
|
||
const db = new DB(config); | ||
const feed = new Feed(db); | ||
feed.start(); // TODO use feed.resume() | ||
feed.on('error', err => { | ||
console.error(err); | ||
}); | ||
|
||
const intervalId = setIntervalAsync( | ||
() => { | ||
return db.updateScores(); | ||
}, | ||
5 * 60 * 1000, | ||
err => console.error(err) | ||
); | ||
|
||
const app = express(); | ||
app.use( | ||
webpackDevMiddleware(compiler, { | ||
publicPath: webpackConfig.output.publicPath | ||
}) | ||
); | ||
app.use(webpackHotMiddleware(compiler)); | ||
|
||
app.use(assets(config)); | ||
app.use(rapid(config)); | ||
|
||
const server = http.createServer(app); | ||
|
||
const port = 3000; | ||
server.listen(port, () => { | ||
console.log(`server listenning on port ${port}`); | ||
}); | ||
|
||
process.once('SIGINT', function() { | ||
server.close(() => { | ||
clearIntervalAsync(intervalId); | ||
feed.stop(); | ||
process.exit(); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,25 @@ | ||
import http from 'http'; | ||
import express from 'express'; | ||
import webpack from 'webpack'; | ||
import webpackDevMiddleware from 'webpack-dev-middleware'; | ||
import webpackHotMiddleware from 'webpack-hot-middleware'; | ||
import webpackConfig from '../webpack.config'; | ||
import DB from '../src/db/db'; | ||
import Feed from '../src/db/feed'; | ||
import { rapid, assets } from './index'; | ||
import { | ||
setIntervalAsync, | ||
clearIntervalAsync | ||
} from './utils/set-interval-async'; | ||
|
||
const compiler = webpack(webpackConfig); | ||
|
||
const config = { | ||
isBeta: true, | ||
disableSsr: true | ||
}; | ||
|
||
const db = new DB(config); | ||
const feed = new Feed(db); | ||
feed.start(); // TODO use feed.resume() | ||
feed.on('error', err => { | ||
console.error(err); | ||
}); | ||
|
||
const intervalId = setIntervalAsync( | ||
() => { | ||
return db.updateScores(); | ||
}, | ||
5 * 60 * 1000, | ||
err => console.error(err) | ||
); | ||
|
||
const app = express(); | ||
app.use( | ||
webpackDevMiddleware(compiler, { | ||
publicPath: webpackConfig.output.publicPath | ||
}) | ||
); | ||
app.use(webpackHotMiddleware(compiler)); | ||
|
||
app.use(assets(config)); | ||
app.use(rapid(config)); | ||
|
||
const server = http.createServer(app); | ||
|
||
const port = 3000; | ||
const port = process.env.PORT || 3000; | ||
server.listen(port, () => { | ||
console.log(`server listenning on port ${port}`); | ||
}); | ||
|
||
process.once('SIGINT', function() { | ||
server.close(() => { | ||
clearIntervalAsync(intervalId); | ||
feed.stop(); // TODO store latest seq to disk ? | ||
process.exit(); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import http from 'http'; | ||
import express from 'express'; | ||
import DB from '../src/db/db'; | ||
import Feed from '../src/db/feed'; | ||
import { | ||
setIntervalAsync, | ||
clearIntervalAsync | ||
} from './utils/set-interval-async'; | ||
|
||
let lastSeq = null; | ||
let lastErr = null; | ||
let lastDateScoreUpdated = null; | ||
|
||
const config = { | ||
isBeta: true, | ||
disableSsr: true | ||
}; | ||
|
||
const db = new DB(config); | ||
const feed = new Feed(db); | ||
feed.resume(); | ||
feed.on('error', err => { | ||
console.error(err); | ||
}); | ||
feed.on('start', seq => { | ||
lastSeq = seq; | ||
}); | ||
feed.on('sync', seq => { | ||
lastSeq = seq; | ||
}); | ||
feed.on('error', err => { | ||
lastErr = err; | ||
}); | ||
|
||
const intervalId = setIntervalAsync( | ||
() => { | ||
lastDateScoreUpdated = new Date().toISOString(); | ||
return db.updateScores(); | ||
}, | ||
5 * 60 * 1000, | ||
err => console.error(err) | ||
); | ||
|
||
const app = express(); | ||
|
||
app.get('/', (req, res, next) => { | ||
res.json({ lastSeq, lastErr, lastDateScoreUpdated }); | ||
}); | ||
|
||
const server = http.createServer(app); | ||
|
||
const port = process.env.PORT || 3000; | ||
server.listen(port, () => { | ||
console.log(`server listenning on port ${port}`); | ||
}); | ||
|
||
process.once('SIGINT', function() { | ||
server.close(() => { | ||
clearIntervalAsync(intervalId); | ||
feed.stop(); | ||
process.exit(); | ||
}); | ||
}); |
This file contains 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