Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom healthcheck of status service #3280

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,25 @@ services:

# nginx
nginx:
build:
context: ../src/web
dockerfile: Dockerfile
cache_from:
- docker.cdot.systems/nginx:buildcache
# next.js needs build-time access to a number of API URL values, forward as ARGs
args:
# Web front-end URL
- WEB_URL=${WEB_URL}
# Telescope 1.0 API URL
- API_URL=${API_URL}
# Telescope 2.0 Microservice URLs
- IMAGE_URL=${IMAGE_URL}
- SSO_URL=${SSO_URL}
- POSTS_URL=${POSTS_URL}
- SEARCH_URL=${SEARCH_URL}
- FEED_DISCOVERY_URL=${FEED_DISCOVERY_URL}
- STATUS_URL=${STATUS_URL}
- GIT_COMMIT=${GIT_COMMIT}
container_name: 'nginx'
environment:
- TELESCOPE_HOST
Expand Down
90 changes: 0 additions & 90 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/api/status/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"bootstrap": "5.1.3",
"express": "4.17.3",
"express-handlebars": "6.0.3",
"get-repo-package-json": "2.0.0",
"npm-run-all": "4.1.5",
"perfect-scrollbar": "1.5.5",
"sass": "1.49.9",
Expand Down
14 changes: 0 additions & 14 deletions src/api/status/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { static: serveStatic } = require('express');
const path = require('path');
const { engine } = require('express-handlebars');
const fs = require('fs/promises');
const getPackage = require('get-repo-package-json');
const { check } = require('./services.js');
const getGitHubData = require('./js/github-stats.js');
const getFeedCount = require('./js/feed-stats.js');
Expand Down Expand Up @@ -49,19 +48,6 @@ const satelliteOptions = {
},
},
},
healthCheck: async (req, res) => {
const sha = process.env.GIT_COMMIT || 'master';
const gitHubUrl = `https://github.com/Seneca-CDOT/telescope/commit/${sha}`;
const { version } = await getPackage('https://github.com/Seneca-CDOT/telescope/blob/master/');

res.set('Cache-Control', 'public, max-age=300');

return {
version,
sha,
gitHubUrl,
};
},
};

const service = new Satellite(satelliteOptions);
Expand Down
5 changes: 4 additions & 1 deletion src/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ ARG FEED_DISCOVERY_URL
ENV NEXT_PUBLIC_FEED_DISCOVERY_URL ${FEED_DISCOVERY_URL}

ARG STATUS_URL
ENV NEXT_PUBLIC_STATUS_URL ${STATUS_URL}}
ENV NEXT_PUBLIC_STATUS_URL ${STATUS_URL}

ARG WEB_URL
ENV NEXT_PUBLIC_WEB_URL ${WEB_URL}

ARG GIT_COMMIT
ENV NEXT_PUBLIC_GIT_COMMIT ${GIT_COMMIT}

RUN npm install --no-package-lock

RUN npm run build
Expand Down
1 change: 1 addition & 0 deletions src/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const envVarsToForward = [
'SEARCH_URL',
'FEED_DISCOVERY_URL',
'STATUS_URL',
'GIT_COMMIT',
];

// Copy an existing ENV Var so it's visible to next: API_URL -> NEXT_PUBLIC_API_URL
Expand Down
18 changes: 12 additions & 6 deletions src/web/src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BsInfoCircle } from 'react-icons/bs';
import { makeStyles, Theme, createStyles, Typography, Fab } from '@material-ui/core';
import smoothscroll from 'smoothscroll-polyfill';
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
import { telescopeUrl, webUrl, statusUrl } from '../config';
import { gitCommitSha, webUrl, statusUrl } from '../config';
import BannerDynamicItems from './BannerDynamicItems';
import BannerButtons from './BannerButtons';
import ScrollAction from './ScrollAction';
Expand Down Expand Up @@ -142,15 +142,21 @@ export default function Banner({ onVisibilityChange, bannerVisible }: BannerProp
useEffect(() => {
async function getGitData() {
try {
const res = await fetch(`${telescopeUrl}/health`);
const sha = gitCommitSha || 'master';
const gitHubUrl = `https://github.com/Seneca-CDOT/telescope/commit/${sha}`;

const response = await fetch(
`https://raw.githubusercontent.com/Seneca-CDOT/telescope/${sha}/package.json`
);

// Fetch failure
if (!res.ok) {
throw new Error(res.statusText);
if (!response.ok) {
throw new Error(response.statusText);
}

const data = await res.json();
setGitInfo(data.info);
const { version } = await response.json();

setGitInfo({ gitHubUrl, sha, version });
} catch (error) {
console.error(`Error retrieving site's health info`, error);
}
Expand Down
4 changes: 4 additions & 0 deletions src/web/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const searchServiceUrl = process.env.NEXT_PUBLIC_SEARCH_URL;
const feedDiscoveryServiceUrl = process.env.NEXT_PUBLIC_FEED_DISCOVERY_URL;
const statusUrl = process.env.NEXT_PUBLIC_STATUS_URL;

// Github sha commit
const gitCommitSha = process.env.NEXT_PUBLIC_GIT_COMMIT;

const title = `Telescope`;
const description = `A tool for tracking blogs in orbit around Seneca's open source involvement`;
const author = `SDDS Students and Professors`;
Expand Down Expand Up @@ -46,4 +49,5 @@ export {
searchServiceUrl,
feedDiscoveryServiceUrl,
statusUrl,
gitCommitSha,
};