Merge pull request #1187 from SkynetLabs/fix-transitioning-to-cli-command

fix transitioning to cli command
This commit is contained in:
Ivaylo Novakov 2021-09-15 13:05:32 +02:00 committed by GitHub
commit b26d2d2c3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 9 deletions

View File

@ -4,11 +4,13 @@ RUN apk update && apk add dnsmasq
WORKDIR /usr/app WORKDIR /usr/app
ENV PATH="/usr/app/bin:${PATH}"
# schedule critical checks to run every 5 minutes (any failures will disable server) # schedule critical checks to run every 5 minutes (any failures will disable server)
RUN echo '*/5 * * * * /usr/app/cli/run critical > /dev/stdout' >> /etc/crontabs/root RUN echo '*/5 * * * * /usr/app/bin/cli run critical > /dev/stdout' >> /etc/crontabs/root
# schedule extended checks to run on every hour (optional checks, report only) # schedule extended checks to run on every hour (optional checks, report only)
RUN echo '0 * * * * /usr/app/cli/run extended > /dev/stdout' >> /etc/crontabs/root RUN echo '0 * * * * /usr/app/bin/cli run extended > /dev/stdout' >> /etc/crontabs/root
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
@ -16,6 +18,7 @@ RUN yarn --frozen-lockfile
COPY src src COPY src src
COPY cli cli COPY cli cli
COPY bin bin
EXPOSE 3100 EXPOSE 3100
ENV NODE_ENV production ENV NODE_ENV production

View File

@ -3,12 +3,15 @@
process.env.NODE_ENV = process.env.NODE_ENV || "production"; process.env.NODE_ENV = process.env.NODE_ENV || "production";
require("yargs/yargs")(process.argv.slice(2)) require("yargs/yargs")(process.argv.slice(2))
.help()
.demandCommand()
.strict(true)
.command( .command(
"enable", "enable",
"Mark portal as enabled", "Mark portal as enabled",
() => {}, () => {},
() => { () => {
const db = require("./src/db"); const db = require("../src/db");
db.set("disabled", false).write(); db.set("disabled", false).write();
} }
@ -18,7 +21,7 @@ require("yargs/yargs")(process.argv.slice(2))
"Mark portal as disabled (provide meaningful reason)", "Mark portal as disabled (provide meaningful reason)",
() => {}, () => {},
({ reason }) => { ({ reason }) => {
const db = require("./src/db"); const db = require("../src/db");
db.set("disabled", reason).write(); db.set("disabled", reason).write();
} }
@ -49,10 +52,10 @@ require("yargs/yargs")(process.argv.slice(2))
process.env.STATE_DIR = stateDir; process.env.STATE_DIR = stateDir;
const util = require("util"); const util = require("util");
const { getYesterdayISOString } = require("./src/utils"); const { getYesterdayISOString } = require("../src/utils");
const createMiddleware = require("./src/checks/middleware"); const createMiddleware = require("../src/checks/middleware");
const db = require("./src/db"); const db = require("../src/db");
const checks = require(`./src/checks/${type}`); const checks = require(`../src/checks/${type}`);
const middleware = await createMiddleware(); const middleware = await createMiddleware();
const entry = { const entry = {

View File

@ -0,0 +1,3 @@
#!/bin/ash
/usr/app/bin/cli disable $@

View File

@ -0,0 +1,3 @@
#!/bin/ash
/usr/app/bin/cli enable $@

3
packages/health-check/cli/run Executable file
View File

@ -0,0 +1,3 @@
#!/bin/ash
/usr/app/bin/cli run $0

View File

@ -16,7 +16,7 @@ docker --version # sanity check
sudo usermod -aG docker user sudo usermod -aG docker user
# Install docker-compose # Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version # sanity check docker-compose --version # sanity check