feat(monitoring): change logger to pino
This changes the logger used to be pino, which print the logs on a single line per log event
This commit is contained in:
parent
8a3481ea8b
commit
9b24bd0c41
8 changed files with 16 additions and 64 deletions
|
|
@ -28,8 +28,10 @@ export const useDatabase = fp<FastifyPluginAsync>(async function(
|
||||||
if (dbAdded) { return; }
|
if (dbAdded) { return; }
|
||||||
dbAdded = true;
|
dbAdded = true;
|
||||||
const path = process.env.DATABASE_DIR;
|
const path = process.env.DATABASE_DIR;
|
||||||
if (isNullish(path)) { throw 'env `DATABASE_DIR` not defined'; }
|
if (isNullish(path)) {
|
||||||
f.log.info(`Opening database with path: ${path}/database.db`);
|
f.log.fatal('env `DATABASE_DIR` not defined');
|
||||||
|
throw 'env `DATABASE_DIR` not defined';
|
||||||
|
}
|
||||||
const db: Database = new DbImpl(`${path}/database.db`) as Database;
|
const db: Database = new DbImpl(`${path}/database.db`) as Database;
|
||||||
if (!f.hasDecorator('db')) { f.decorate('db', db); }
|
if (!f.hasDecorator('db')) { f.decorate('db', db); }
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { FastifyReply } from 'fastify';
|
||||||
import fp from 'fastify-plugin';
|
import fp from 'fastify-plugin';
|
||||||
|
|
||||||
export const useMonitoring = fp(async (fastify) => {
|
export const useMonitoring = fp(async (fastify) => {
|
||||||
fastify.get('/monitoring', { schema: { hide: true } }, (req, res) => {
|
fastify.get('/monitoring', { schema: { hide: true }, logLevel: 'silent' }, (req, res) => {
|
||||||
void req;
|
void req;
|
||||||
res.code(200).send('Ok');
|
res.code(200).send('Ok');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
# do anything here
|
# do anything here
|
||||||
|
|
||||||
mkdir -p /volumes/static/auth/
|
|
||||||
cp -r /extra/login_demo.html /volumes/static/auth/index.html
|
|
||||||
cp -r /extra/login_demo.js /volumes/static/auth/login_demo.js
|
|
||||||
|
|
||||||
# run the CMD [ ... ] from the dockerfile
|
# run the CMD [ ... ] from the dockerfile
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,9 @@ import fastify, { FastifyInstance } from 'fastify';
|
||||||
import app from './app';
|
import app from './app';
|
||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
const envToLogger = {
|
const f: FastifyInstance = fastify({ logger: { level: 'info' } });
|
||||||
development: {
|
|
||||||
transport: {
|
|
||||||
target: 'pino-pretty',
|
|
||||||
options: {
|
|
||||||
translateTime: 'HH:MM:ss Z',
|
|
||||||
ignore: 'pid,hostname',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
production: true,
|
|
||||||
test: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const f: FastifyInstance = fastify({ logger: envToLogger.development });
|
|
||||||
process.on('SIGTERM', () => {
|
process.on('SIGTERM', () => {
|
||||||
f.log.info('Requested to shutdown');
|
f.log.warn('Requested to shutdown');
|
||||||
process.exit(134);
|
process.exit(134);
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
# do anything here
|
# do anything here
|
||||||
|
|
||||||
# run the CMD [ ... ] from the dockerfile
|
# run the CMD [ ... ] from the dockerfile
|
||||||
|
|
|
||||||
|
|
@ -4,33 +4,18 @@ import fastify, { FastifyInstance } from 'fastify';
|
||||||
import app from './app';
|
import app from './app';
|
||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
const envToLogger = {
|
const f: FastifyInstance = fastify({ logger: { level: 'info' } });
|
||||||
development: {
|
process.on('SIGTERM', () => {
|
||||||
transport: {
|
f.log.warn('Requested to shutdown');
|
||||||
target: 'pino-pretty',
|
process.exit(134);
|
||||||
options: {
|
});
|
||||||
translateTime: 'HH:MM:ss Z',
|
|
||||||
ignore: 'pid,hostname',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
production: true,
|
|
||||||
test: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const f: FastifyInstance = fastify({ logger: envToLogger.development });
|
|
||||||
try {
|
try {
|
||||||
process.on('SIGTERM', () => {
|
|
||||||
f.log.info('Requested to shutdown');
|
|
||||||
process.exit(134);
|
|
||||||
});
|
|
||||||
console.log('-------->Serving static files from:');
|
|
||||||
await f.register(app, {});
|
await f.register(app, {});
|
||||||
await f.listen({ port: 80, host: '0.0.0.0' });
|
await f.listen({ port: 80, host: '0.0.0.0' });
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
f.log.error(err);
|
f.log.error(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
start();
|
start();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
# do anything here
|
# do anything here
|
||||||
|
|
||||||
# run the CMD [ ... ] from the dockerfile
|
# run the CMD [ ... ] from the dockerfile
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,9 @@ import fastify, { FastifyInstance } from 'fastify';
|
||||||
import app from './app';
|
import app from './app';
|
||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
const envToLogger = {
|
const f: FastifyInstance = fastify({ logger: { level: 'info' } });
|
||||||
development: {
|
|
||||||
transport: {
|
|
||||||
target: 'pino-pretty',
|
|
||||||
options: {
|
|
||||||
translateTime: 'HH:MM:ss Z',
|
|
||||||
ignore: 'pid,hostname',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
production: true,
|
|
||||||
test: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const f: FastifyInstance = fastify({ logger: envToLogger.development });
|
|
||||||
process.on('SIGTERM', () => {
|
process.on('SIGTERM', () => {
|
||||||
f.log.info('Requested to shutdown');
|
f.log.warn('Requested to shutdown');
|
||||||
process.exit(134);
|
process.exit(134);
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue