fix transitioning to cli command

This commit is contained in:
Karol Wypchlo 2021-09-15 12:50:22 +02:00
parent ebb34a54a2
commit b768ca9973
No known key found for this signature in database
GPG Key ID: C92C016317A964D0
6 changed files with 23 additions and 8 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,9 +52,9 @@ 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();

View File

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

View File

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

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

@ -0,0 +1,3 @@
#!/bin/ash
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