Skip to content

Commit

Permalink
Allow configuring poll interval with second precision
Browse files Browse the repository at this point in the history
  • Loading branch information
coocos committed Apr 4, 2021
1 parent c78513d commit 7dc4b03
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export default {
port: parseInt(process.env.APP_PORT ?? "8000"),
feed: {
url: process.env.FEED_URL ?? "http://www.peto-media.fi/tiedotteet/rss.xml",
schedule: parseInt(process.env.FEED_SCHEDULE ?? "2"),
schedule: process.env.FEED_SCHEDULE ?? "* * * * *",
},
database: {
host: process.env.DB_HOST,
Expand Down
4 changes: 2 additions & 2 deletions src/cron.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import EventEmitter from "events";
import cron from "node-cron";

import logger from "./logger";
import config from "./config";

import { sqlEventService, feedService } from "./services";

const feedScraper = (): EventEmitter => {
const feedEventEmitter = new EventEmitter();
cron.schedule(`*/${config.feed.schedule} * * * *`, async () => {
cron.schedule(config.feed.schedule, async () => {
const rawFeed = await feedService.decodeFeed();
const events = await feedService.mapFeedToEvents(rawFeed);
for (const event of events) {
Expand Down

0 comments on commit 7dc4b03

Please sign in to comment.