Skip to content

Commit

Permalink
change exec and logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ender-null committed May 8, 2024
1 parent 249f6f9 commit df7a590
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { exec } from 'child_process';
import { execSync } from 'child_process';
import fs from 'fs';
import mime from 'mime-types';
import fetch, { BodyInit, HeadersInit, RequestInit, Response } from 'node-fetch';
Expand Down Expand Up @@ -980,15 +980,14 @@ export const loggerFormat = winstonFormat.printf(({ level, message, timestamp, .
});

export const transport = new winston.transports.DailyRotateFile({
dirname: 'logs',
filename: 'polaris-%DATE%.log',
dirname: '/var/log/polaris',
filename: 'core-%DATE%.log',
datePattern: 'YYYY-MM-DD-HH',
zippedArchive: true,
maxSize: '20m',
maxFiles: '7d',
});

// Configure logger
export const logger = createLogger({
level: 'info',
format: winstonFormat.combine(winstonFormat.timestamp(), winstonFormat.json()),
Expand All @@ -1008,8 +1007,8 @@ export const logger = createLogger({

export const execResult = async (command: string): Promise<string> => {
try {
const { stdout } = await util.promisify(exec)(command);
return stdout;
const stdout = await execSync(command);
return stdout.toString();
} catch (e) {
catchException(e);
return e.message;
Expand Down

0 comments on commit df7a590

Please sign in to comment.