mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-29 13:06:19 +00:00
correr cron dentro de scraper
This commit is contained in:
parent
a438eec238
commit
66fc8767ef
4 changed files with 8 additions and 6 deletions
|
@ -15,7 +15,7 @@ RUN apt-get update && apt-get install -y libsqlite3-dev && rm -rf /var/lib/apt/l
|
|||
RUN cargo install --path .
|
||||
|
||||
FROM docker.io/oven/bun:1-slim
|
||||
RUN apt-get update && apt-get install -y busybox-static sqlite3 && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y sqlite3 && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Scraper
|
||||
COPY --from=build /tmp/cli.build.js /bin/scraper
|
||||
|
@ -25,8 +25,4 @@ COPY --from=rs-build /usr/local/cargo/bin/scraper-rs /usr/local/bin/scraper-rs
|
|||
ENV NODE_ENV=production
|
||||
ENV DB_PATH=/db/db.db
|
||||
|
||||
# Cron scraper
|
||||
RUN mkdir -p /var/spool/cron/crontabs \
|
||||
&& printf "0 2 * * * bun /bin/scraper auto\n" > /var/spool/cron/crontabs/root
|
||||
|
||||
CMD ["busybox", "crond", "-f", "-l2"]
|
||||
CMD ["bun", "/bin/scraper", "cron"]
|
||||
|
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -4,9 +4,14 @@ import { scrapDiaProducts } from "../link-scrapers/dia.js";
|
|||
import { scrapJumboProducts } from "../link-scrapers/jumbo.js";
|
||||
import { auto } from "./auto.js";
|
||||
import { downloadList, getProduct } from "./scrap.js";
|
||||
import Cron from "croner";
|
||||
|
||||
if (process.argv[2] === "auto") {
|
||||
await auto();
|
||||
} else if (process.argv[2] === "cron") {
|
||||
Cron("0 2 * * *", () => {
|
||||
auto();
|
||||
});
|
||||
} else if (process.argv[2] === "scrap-carrefour-links") {
|
||||
await scrapCarrefourProducts();
|
||||
} else if (process.argv[2] === "scrap-dia-links") {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.478.0",
|
||||
"@aws-sdk/lib-storage": "^3.478.0",
|
||||
"croner": "^8.0.0",
|
||||
"date-fns": "^3.0.6",
|
||||
"db-datos": "workspace:^",
|
||||
"drizzle-orm": "^0.29.1",
|
||||
|
|
Loading…
Reference in a new issue