Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
neSpecc committed Jan 31, 2025
1 parent 06b8a04 commit ae3798c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
18 changes: 17 additions & 1 deletion runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if (process.env.HAWK_CATCHER_TOKEN) {
HawkCatcher.init(process.env.HAWK_CATCHER_TOKEN);
}

console.log('process.env', process.env);

type WorkerConstructor = new () => Worker;

const BEGINNING_OF_ARGS = 2;
Expand All @@ -27,6 +29,8 @@ const BEGINNING_OF_ARGS = 2;
*/
const workerNames = process.argv.slice(BEGINNING_OF_ARGS);

console.log('workerNames', workerNames);

/**
* Workers dispatcher.
* Load, run and finish workers.
Expand Down Expand Up @@ -55,6 +59,8 @@ class WorkerRunner {
*/
this.loadPackages()
.then((workerConstructors) => {
console.log('packages loaded');

this.constructWorkers(workerConstructors);
})
// .then(() => {
Expand Down Expand Up @@ -165,8 +171,12 @@ class WorkerRunner {
* @param workerConstructors - worker constructors to create new instances
*/
private constructWorkers(workerConstructors: WorkerConstructor[]): void {
console.log('constructWorkers', workerConstructors);

return workerConstructors.forEach((WorkerClass) => {
try {
console.log('constructing worker', WorkerClass);

const worker = new WorkerClass();

this.workers.push(worker);
Expand Down Expand Up @@ -302,5 +312,11 @@ class WorkerRunner {
}
}

console.log('Starting worker runner');

// eslint-disable-next-line no-new
new WorkerRunner();
try {
new WorkerRunner();
} catch (error) {
console.error('Error running worker runner', error);
}
6 changes: 5 additions & 1 deletion workers/grouper/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ export default class GrouperWorker extends Worker {
* Start consuming messages
*/
public async start(): Promise<void> {
console.log('starting grouper worker');

await this.db.connect();
this.prepareCache();
await this.redis.initialize();
console.log('redis initializing');

await this.redis.initialize();
console.log('redis initialized');
await super.start();
}

Expand Down
7 changes: 6 additions & 1 deletion workers/grouper/src/redisHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ export default class RedisHelper {
*/
constructor() {
try {
this.redisClient = createClient({ url: process.env.REDIS_URL });
console.log('redis constructor', process.env.REDIS_URL);


this.redisClient = createClient({ url: process.env.REDIS_URL });

this.redisClient.on('error', (error) => {
console.log('redis error', error);

if (error) {
this.logger.error('Redis error: ', error);
HawkCatcher.send(error);
Expand Down

0 comments on commit ae3798c

Please sign in to comment.