You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-10 22:11:50 +02:00
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
import * as Koa from 'koa';
|
import * as Koa from 'koa';
|
||||||
import Logger from '@joplin/utils/Logger';
|
import Logger, { LoggerWrapper } from '@joplin/utils/Logger';
|
||||||
import koaBody from 'koa-body';
|
import koaBody from 'koa-body';
|
||||||
import initiateLogger from '../services/initiateLogger';
|
import initiateLogger from '../services/initiateLogger';
|
||||||
import createQueue from '../services/createQueue';
|
import createQueue from '../services/createQueue';
|
||||||
@@ -10,12 +10,11 @@ import env, { EnvVariables } from '../env';
|
|||||||
import HtrCli from '../core/HtrCli';
|
import HtrCli from '../core/HtrCli';
|
||||||
import JobProcessor from '../workers/JobProcessor';
|
import JobProcessor from '../workers/JobProcessor';
|
||||||
|
|
||||||
initiateLogger();
|
|
||||||
const logger = Logger.create('api/app');
|
|
||||||
|
|
||||||
const init = async () => {
|
const init = async (logger: LoggerWrapper) => {
|
||||||
const envVariables = env();
|
const envVariables = env();
|
||||||
|
|
||||||
|
logger.info('Checking configurations');
|
||||||
await checkServerConfigurations(envVariables);
|
await checkServerConfigurations(envVariables);
|
||||||
|
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
@@ -26,6 +25,7 @@ const init = async () => {
|
|||||||
|
|
||||||
await router(app, envVariables.API_KEY);
|
await router(app, envVariables.API_KEY);
|
||||||
|
|
||||||
|
logger.info('Creating queue');
|
||||||
const queue = await createQueue(envVariables, true);
|
const queue = await createQueue(envVariables, true);
|
||||||
|
|
||||||
const fileStorage = new FileStorage();
|
const fileStorage = new FileStorage();
|
||||||
@@ -39,6 +39,7 @@ const init = async () => {
|
|||||||
|
|
||||||
logger.info('Starting worker');
|
logger.info('Starting worker');
|
||||||
await jobProcessor.init();
|
await jobProcessor.init();
|
||||||
|
logger.info('Server started successfully');
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkServerConfigurations = (envVariables: EnvVariables) => {
|
const checkServerConfigurations = (envVariables: EnvVariables) => {
|
||||||
@@ -47,12 +48,13 @@ const checkServerConfigurations = (envVariables: EnvVariables) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
|
initiateLogger();
|
||||||
|
const logger = Logger.create('api/app');
|
||||||
logger.info('Starting...');
|
logger.info('Starting...');
|
||||||
await init();
|
await init(logger);
|
||||||
};
|
};
|
||||||
|
|
||||||
main().catch(error => {
|
main().catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
logger.error(error);
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user