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

Allow using environment variables to configure the exporter. #422

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const path = require('path');
const logger = require('./lib/logger');

// Check if there is a `apps.json` in the config folder
if (!fs.existsSync(path.resolve(__dirname, '../config/apps.json'))) {
if (!process.env.APPS && !fs.existsSync(path.resolve(__dirname, '../config/apps.json'))) {
logger.error(
'Please copy the file "src/examples/apps.json" => "config/apps.json"',
);
process.exit(1);
}

// Check if there is a `config.json` in the config folder
if (!fs.existsSync(path.resolve(__dirname, '../config/config.json'))) {
if (!process.env.CONFIG && !fs.existsSync(path.resolve(__dirname, '../config/config.json'))) {
logger.error(
'Please copy the file "src/examples/config.json" => "config/config.json"',
);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/prometheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const client = require('prom-client');
const itunes = require('app-store-scraper');
const gplay = require('google-play-scraper');

// Config files
const config = require('../../config/config.json');
const apps = require('../../config/apps.json');
const metrics = require('../config/metrics.json');
// get config from docker environment variables or config files
const config = process.env.CONFIG ? JSON.parse(process.env.CONFIG) : require('../../config/config.json');
const apps = process.env.APPS ? JSON.parse(process.env.APPS) : require('../../config/apps.json');
const metrics = process.env.METRICS ? JSON.parse(process.env.METRICS) : require('../config/metrics.json');

const register = new client.Registry();

Expand Down