Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logperf5 #4030

Open
wants to merge 22 commits into
base: master-qa
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
"@typescript-eslint/explicit-member-accessibility": "off",
"jsdoc/require-jsdoc": "off",
"indent": "off",
"@typescript-eslint/unbound-method": [
"error",
{
"ignoreStatic": true
}
],
"@typescript-eslint/indent": [
"error",
2,
Expand Down Expand Up @@ -138,7 +144,7 @@
"max-len": [
"warn",
{
"code": 180,
"code": 220,
"ignoreComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
Expand Down
17 changes: 17 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
apps: [{
env: {
NODE_ENV: "development",
SERVER_ROLE: "ocppj"
},
name: "pm2 - ocppj - server",
script: "./dist/start.js"
}, {
env: {
NODE_ENV: "development",
SERVER_ROLE: "rest"
},
name: "pm2 - rest server",
script: "./dist/start.js"
}]
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"start": "npm version && npm run start:prod",
"start:dev": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development-build node -r source-map-support/register dist/start.js",
"start:dev:debug": "npm version && cross-env NODE_ENV=development ts-node-dev --inspect --files --max-old-space-size=4096 -- src/start.ts",
"start:dev:debug:ocppj": "npm version && cross-env SERVER_ROLE=ocppj NODE_ENV=development ts-node-dev --inspect --files --max-old-space-size=4096 -- src/start.ts",
"start:dev:debug:rest": "npm version && cross-env SERVER_ROLE=rest NODE_ENV=development ts-node-dev --inspect --files --max-old-space-size=4096 -- src/start.ts",
"start:dev:debug:ocppj": "npm version && cross-env SERVER_ROLE=ocppj NODE_ENV=development ts-node-dev --inspect --files -- src/start.ts",
"start:dev:debug:rest": "npm version && cross-env SERVER_ROLE=rest NODE_ENV=development ts-node-dev --files -- src/start.ts",
"start:dev:debug:nodemon": "npm version && nodemon --exec \"ts-node --files\" src/start.ts 9229",
"start:dev:nodemon": "npm version && nodemon --exec \"ts-node --files\" src/start.ts",
"start:dev:prof": "npm version && cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" NODE_ENV=development node -r source-map-support/register --prof -- dist/start.js",
Expand Down Expand Up @@ -157,7 +157,7 @@
"tslib": "^2.4.0",
"tz-lookup": "^6.1.25",
"urlencode": "^1.1.0",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.10.0",
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.15.0",
"validator": "^13.7.0",
"ws": "^8.10.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/AsyncTaskBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class AsyncTaskBuilder {
// Save
await AsyncTaskStorage.saveAsyncTask(asyncTask as AsyncTask);
// Log
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'createAndSaveAsyncTasks',
Expand Down
14 changes: 7 additions & 7 deletions src/async-task/AsyncTaskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class AsyncTaskManager {

public static async handleAsyncTasks(): Promise<void> {
let failedToAcquireLock = false;
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -75,7 +75,7 @@ export default class AsyncTaskManager {
{ status: AsyncTaskStatus.PENDING }, Constants.DB_PARAMS_MAX_LIMIT);
// Process them
if (!Utils.isEmptyArray(asyncTasks.result)) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -98,7 +98,7 @@ export default class AsyncTaskManager {
asyncTask.lastChangedOn = asyncTask.execTimestamp;
await AsyncTaskStorage.saveAsyncTask(asyncTask);
// Log
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -115,7 +115,7 @@ export default class AsyncTaskManager {
await AsyncTaskStorage.saveAsyncTask(asyncTask);
processedTask.inSuccess++;
// Log
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand All @@ -130,7 +130,7 @@ export default class AsyncTaskManager {
asyncTask.lastChangedOn = new Date();
await AsyncTaskStorage.saveAsyncTask(asyncTask);
// Log error
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
module: MODULE_NAME, method: 'handleAsyncTasks',
action: ServerAction.ASYNC_TASK,
Expand Down Expand Up @@ -162,7 +162,7 @@ export default class AsyncTaskManager {
void AsyncTaskManager.handleAsyncTasks();
}
} else {
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class AsyncTaskManager {
case AsyncTasks.OCPI_PUSH_EVSE_STATUSES:
return new OCPIPushEVSEStatusesAsyncTask(asyncTask, correlationID);
default:
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'handleAsyncTasks',
Expand Down
16 changes: 8 additions & 8 deletions src/async-task/TenantAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
(taskSettings.task.disableAllTasks || !Utils.isEmptyArray(taskSettings.task.disableTasksInEnv) && taskSettings.task.disableTasksInEnv.includes(currentTaskEnv))) {
// Tasks are disabled for this environment
isTaskExecutionDisabled = true;
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -43,7 +43,7 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
}
// Check if tenant task needs to run on a specific env
if (tenant.taskExecutionEnv && tenant.taskExecutionEnv !== currentTaskEnv) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -54,13 +54,13 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
}
const tenantCorrelationID = Utils.generateShortNonUniqueID();
const startTimeInTenant = moment();
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
message: `The Task '${this.getAsyncTask().name}~${this.getCorrelationID()}~${tenantCorrelationID}' is running for Tenant ${Utils.buildTenantName(tenant)}...`
});
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -74,14 +74,14 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
// Hook
await this.afterExecuteTenantAsyncTask(tenant);
} catch (error) {
await Logging.logError({
Logging.beError()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
message: `Error while running the Task '${this.getAsyncTask().name}~${this.getCorrelationID()}~${tenantCorrelationID}' for Tenant ${Utils.buildTenantName(tenant)}: ${error.message as string}`,
detailedMessages: { error: error.stack }
});
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -91,13 +91,13 @@ export default abstract class TenantAsyncTask extends AbstractAsyncTask {
}
// Log Total Processing Time in Tenant
const totalTimeSecsInTenant = moment.duration(moment().diff(startTimeInTenant)).asSeconds();
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: Constants.DEFAULT_TENANT_ID,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
message: `The Task '${this.getAsyncTask().name}~${this.getCorrelationID()}~${tenantCorrelationID}' has been run successfully in ${totalTimeSecsInTenant} secs for Tenant ${Utils.buildTenantName(tenant)}`
});
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.ASYNC_TASK,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/BillTransactionAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class BillTransactionAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.BILLING_TRANSACTION, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.BILLING_TRANSACTION, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ImportHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class ImportHelper {
await UserStorage.addSiteToUser(tenant, user.id, importedSiteID);
} else {
// Site does not exist
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/SynchronizeCarCatalogsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class SynchronizeCarCatalogsAsyncTask extends AbstractAsyncTask {
await carDatabaseImpl.synchronizeCarCatalogs();
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(Constants.DEFAULT_TENANT_ID, ServerAction.SYNCHRONIZE_CAR_CATALOGS, error);
Logging.logActionExceptionMessage(Constants.DEFAULT_TENANT_ID, ServerAction.SYNCHRONIZE_CAR_CATALOGS, error);
} finally {
// Release the lock
await LockingManager.release(syncCarCatalogsLock);
Expand Down
8 changes: 4 additions & 4 deletions src/async-task/tasks/TagsImportAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
// Get total number of Tags to import
const totalTagsToImport = await TagStorage.getImportedTagsCount(tenant);
if (totalTagsToImport > 0) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: tenant.id,
action: ServerAction.TAGS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -66,7 +66,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
importedTag.errorDescription = error.message;
result.inError++;
await TagStorage.saveImportedTag(tenant, importedTag);
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.TAGS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -77,7 +77,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
}
if (!Utils.isEmptyArray(importedTags.result) && (result.inError + result.inSuccess) > 0) {
const intermediateDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.TAGS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -95,7 +95,7 @@ export default class TagsImportAsyncTask extends AbstractAsyncTask {
);
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(tenant.id, ServerAction.TAGS_IMPORT, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.TAGS_IMPORT, error);
} finally {
// Release the lock
await LockingManager.release(importTagsLock);
Expand Down
8 changes: 4 additions & 4 deletions src/async-task/tasks/UsersImportAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
// Get total number of Users to import
const totalUsersToImport = await UserStorage.getImportedUsersCount(tenant);
if (totalUsersToImport > 0) {
await Logging.logInfo({
Logging.beInfo()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -66,7 +66,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
result.inError++;
// Update it
await UserStorage.saveImportedUser(tenant, importedUser);
await Logging.logError({
Logging.beError()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'executeAsyncTask',
Expand All @@ -77,7 +77,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
}
if (importedUsers.result.length > 0 && (result.inError + result.inSuccess) > 0) {
const intermediateDurationSecs = Math.round((new Date().getTime() - startTime) / 1000);
await Logging.logDebug({
Logging.beDebug()?.log({
tenantID: tenant.id,
action: ServerAction.USERS_IMPORT,
module: MODULE_NAME, method: 'processTenant',
Expand All @@ -95,7 +95,7 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
);
} catch (error) {
// Log error
await Logging.logActionExceptionMessage(tenant.id, ServerAction.USERS_IMPORT, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.USERS_IMPORT, error);
} finally {
// Release the lock
await LockingManager.release(importUsersLock);
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPICheckCdrsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPICheckCdrsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_CDRS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_CDRS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPICheckLocationsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPICheckLocationsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_LOCATIONS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_LOCATIONS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPICheckSessionsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPICheckSessionsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_SESSIONS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_CHECK_SESSIONS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullCdrsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullCdrsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_CDR, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_CDR, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullLocationsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullLocationsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_LOCATIONS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_LOCATIONS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullSessionsAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullSessionsAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_SESSION, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_GET_SESSION, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPullTokensAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPullTokensAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_GET_TOKENS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_GET_TOKENS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPushEVSEStatusesAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class OCPIPushEVSEStatusesAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_UPDATE_STATUS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_CPO_UPDATE_STATUS, error);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/async-task/tasks/ocpi/OCPIPushTokensAsyncTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class OCPIPushTokensAsyncTask extends AbstractAsyncTask {
}
}
} catch (error) {
await Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_UPDATE_TOKENS, error);
Logging.logActionExceptionMessage(tenant.id, ServerAction.OCPI_EMSP_UPDATE_TOKENS, error);
}
}
}
Expand Down
Loading