diff --git a/cli/src/datafeed.ts b/cli/src/datafeed.ts index 5b13cabcb..43a7b9194 100644 --- a/cli/src/datafeed.ts +++ b/cli/src/datafeed.ts @@ -40,6 +40,16 @@ import { listHandler as reporterListHandler, removeHandler as reporterRemoveHandler } from './reporter' +import { + FETCHER_HOST, + FETCHER_PORT, + LISTENER_SERVICE_HOST, + LISTENER_SERVICE_PORT, + REPORTER_SERVICE_HOST, + REPORTER_SERVICE_PORT, + WORKER_SERVICE_HOST, + WORKER_SERVICE_PORT +} from './settings' import { isValidUrl, loadJsonFromUrl } from './utils' export function datafeedSub() { @@ -231,17 +241,15 @@ export function bulkActivateHandler() { const chain = bulkData?.chain || 'localhost' const service = bulkData?.service || 'DATA_FEED' - const fetcherHost = bulkData?.fetcherHost || 'http://fetcher.orakl.svc.cluster.local' - const workerHost = bulkData?.workerHost || 'http://aggregator-worker.orakl.svc.cluster.local' - const listenerHost = - bulkData?.listenerHost || 'http://aggregator-listener.orakl.svc.cluster.local' - const reporterHost = - bulkData?.reporterHost || 'http://aggregator-reporter.orakl.svc.cluster.local' + const fetcherHost = bulkData?.fetcherHost || FETCHER_HOST + const workerHost = bulkData?.workerHost || WORKER_SERVICE_HOST + const listenerHost = bulkData?.listenerHost || LISTENER_SERVICE_HOST + const reporterHost = bulkData?.reporterHost || REPORTER_SERVICE_HOST - const fetcherPort = bulkData?.fetcherPort || '4040' - const workerPort = bulkData?.workerPort || '5000' - const listenerPort = bulkData?.listenerPort || '4000' - const reporterPort = bulkData?.reporterPort || '6000' + const fetcherPort = bulkData?.fetcherPort || FETCHER_PORT + const workerPort = bulkData?.workerPort || WORKER_SERVICE_PORT + const listenerPort = bulkData?.listenerPort || LISTENER_SERVICE_PORT + const reporterPort = bulkData?.reporterPort || REPORTER_SERVICE_PORT const listeners = await listenerListHandler()({ chain, service }) const reporters = await reporterListHandler()({ chain, service }) @@ -311,17 +319,15 @@ export function bulkDeactivateHandler() { const chain = bulkData?.chain || 'localhost' const service = bulkData?.service || 'DATA_FEED' - const fetcherHost = bulkData?.fetcherHost || 'http://fetcher.orakl.svc.cluster.local' - const workerHost = bulkData?.workerHost || 'http://aggregator-worker.orakl.svc.cluster.local' - const listenerHost = - bulkData?.listenerHost || 'http://aggregator-listener.orakl.svc.cluster.local' - const reporterHost = - bulkData?.reporterHost || 'http://aggregator-reporter.orakl.svc.cluster.local' - - const fetcherPort = bulkData?.fetcherPort || '4040' - const workerPort = bulkData?.workerPort || '5000' - const listenerPort = bulkData?.listenerPort || '4000' - const reporterPort = bulkData?.reporterPort || '6000' + const fetcherHost = bulkData?.fetcherHost || FETCHER_HOST + const workerHost = bulkData?.workerHost || WORKER_SERVICE_HOST + const listenerHost = bulkData?.listenerHost || LISTENER_SERVICE_HOST + const reporterHost = bulkData?.reporterHost || REPORTER_SERVICE_HOST + + const fetcherPort = bulkData?.fetcherPort || FETCHER_PORT + const workerPort = bulkData?.workerPort || WORKER_SERVICE_PORT + const listenerPort = bulkData?.listenerPort || LISTENER_SERVICE_PORT + const reporterPort = bulkData?.reporterPort || REPORTER_SERVICE_PORT const listeners = await listenerListHandler()({ chain, service }) const reporters = await reporterListHandler()({ chain, service }) diff --git a/cli/src/settings.ts b/cli/src/settings.ts index d975b2d0f..962c615f7 100644 --- a/cli/src/settings.ts +++ b/cli/src/settings.ts @@ -1,17 +1,44 @@ -export const ORAKL_NETWORK_API_URL = - process.env.ORAKL_NETWORK_API_URL || 'http://localhost:3000/api/v1' +const production = process.env.NODE_ENV == 'production' +const default_api_url = production + ? 'http://api.orakl.svc.cluster.local' + : 'http://localhost:3000/api/v1' +const default_delegator_url = production + ? 'http://delegator.orakl.svc.cluster.local' + : 'http://localhost:3002/api/v1' + +const default_fetcher_host = production + ? 'http://fetcher.orakl.svc.cluster.local' + : 'http://localhost' +const default_fetcher_port = production ? '4040' : '3001' + +const default_listener_host = production + ? 'http://aggregator-listener.orakl.svc.cluster.local' + : 'http://localhost' +const default_listener_port = production ? '4000' : '4000' + +const default_worker_host = production + ? 'http://aggregator-worker.orakl.svc.cluster.local' + : 'http://localhost' +const default_worker_port = production ? '5000' : '5001' + +const default_reporter_host = production + ? 'http://aggregator-reporter.orakl.svc.cluster.local' + : 'http://localhost' +const default_reporter_port = production ? '6000' : '6000' + +export const ORAKL_NETWORK_API_URL = process.env.ORAKL_NETWORK_API_URL || default_api_url export const ORAKL_NETWORK_DELEGATOR_URL = - process.env.ORAKL_NETWORK_DELEGATOR_URL || 'http://localhost:3002/api/v1' + process.env.ORAKL_NETWORK_DELEGATOR_URL || default_delegator_url -export const FETCHER_HOST = 'http://localhost' -export const FETCHER_PORT = 3001 +export const FETCHER_HOST = process.env.FETCHER_HOST || default_fetcher_host +export const FETCHER_PORT = process.env.FETCHER_PORT || default_fetcher_port export const FETCHER_API_VERSION = '/api/v1' -export const LISTENER_SERVICE_HOST = process.env.LISTENER_SERVICE_HOST || 'http://localhost' -export const LISTENER_SERVICE_PORT = process.env.LISTENER_SERVICE_PORT || 4000 +export const LISTENER_SERVICE_HOST = process.env.LISTENER_SERVICE_HOST || default_listener_host +export const LISTENER_SERVICE_PORT = process.env.LISTENER_SERVICE_PORT || default_listener_port -export const WORKER_SERVICE_HOST = process.env.WORKER_SERVICE_HOST || 'http://localhost' -export const WORKER_SERVICE_PORT = process.env.WORKER_SERVICE_PORT || 5001 +export const WORKER_SERVICE_HOST = process.env.WORKER_SERVICE_HOST || default_worker_host +export const WORKER_SERVICE_PORT = process.env.WORKER_SERVICE_PORT || default_worker_port -export const REPORTER_SERVICE_HOST = process.env.REPORTER_SERVICE_HOST || 'http://localhost' -export const REPORTER_SERVICE_PORT = process.env.REPORTER_SERVICE_PORT || 6000 +export const REPORTER_SERVICE_HOST = process.env.REPORTER_SERVICE_HOST || default_reporter_host +export const REPORTER_SERVICE_PORT = process.env.REPORTER_SERVICE_PORT || default_reporter_port