Skip to content

Commit

Permalink
init only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
akvlad committed Jun 11, 2024
1 parent 2944762 commit 3647077
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions qryn_bun.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,29 @@ import handlerTempoLabelV2 from './lib/handlers/tempo_v2_tags.js'
import handlerTempoLabelV2Values from './lib/handlers/tempo_v2_values.js'
import {init as pyroscopeInit } from './pyroscope/pyroscope.js'

import { readonly } from './common.js'
import { boolEnv, readonly } from './common.js'
import DATABASE, { init } from './lib/db/clickhouse.js'
import { startAlerting } from './lib/db/alerting/index.js'
import fs from 'fs'
import path from 'path'
import { file, dir, group, CORS } from '@stricjs/utils';
import auth from 'basic-auth'
import * as errors from 'http-errors'
import logger from './lib/logger.js'

const http_user = process.env.QRYN_LOGIN || process.env.CLOKI_LOGIN || undefined
const http_password = process.env.QRYN_PASSWORD || process.env.CLOKI_PASSWORD || undefined

export default async() => {
await init(process.env.CLICKHOUSE_DB || 'cloki')
try {
await init(process.env.CLICKHOUSE_DB || 'cloki')
if (process.env.MODE === 'init_only') {
process.exit(0)
}
} catch (err) {
logger.error(err, 'Error starting qryn')
process.exit(1)
}
if (!readonly) {
await startAlerting()
}
Expand Down
8 changes: 8 additions & 0 deletions qryn_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ let fastify = require('fastify')({
(async () => {
try {
await init(process.env.CLICKHOUSE_DB || 'cloki')
if (process.env.MODE === 'init_only') {
process.exit(0)
}
} catch (err) {
logger.error(err, 'Error starting qryn')
process.exit(1)
}
try {
if (!this.readonly) {
await startAlerting()
}
Expand Down

0 comments on commit 3647077

Please sign in to comment.