-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow the process manager to configure log files count and sizes #1067
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good.
I added the possibility to configure the log files and whether to run in debug in the config file by default, with always the possibility to override in individual calls, but we don't support it yet. @greenscientist fwiw we can now allow more log files and of larger sizes in our instances and we could support running in debug in some instances if required, batch and not batch separately. |
Kinda wondering if we should just strip all this out and let the standard OS tools handle log management. |
@tahini, as-tu regardé si il existait des modules standard pour gérer tout ça ? |
C'est ce que winston fait, on peut envoyer les logs où on veut. Ceci a l'avantage que qqn qui fait rouler Transition peut contrôler le logging. Si on laisse l'OS faire, il faudrait documenter la procédure ou configurer un autre outil séparément. |
packages/chaire-lib-backend/src/utils/processManagers/OSRMProcessManager.ts
Show resolved
Hide resolved
tagName, | ||
serviceName, | ||
nbFiles = 1, | ||
maxFileSizeKb = 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number here should be a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also why use kilo instead if simply bytes.
The Kb is confusing, it should be KB if you want bytes, Kb would usually means bits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a bit unreleated, but 1 meg is probably a bit small to be the default value. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the current default... fwiw, these values are to keep the current behavior, again fwiw...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults to 3 files of 5MB each now, for the processManager and specifically for trRouting as well
cwd?: string; | ||
attemptRestart?: boolean; | ||
logFiles?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we realely need a struct in a struct? This make calling the function a bit more complex with useful reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debatable, but I'll say that one can leave it blank if they will, but if they want to set it, they'll want to handle the "log file" concept separately form the other 10 parameters that we set, so it might as well be a struct.
@@ -14,6 +14,13 @@ import config from '../../config/server.config'; | |||
// Set 2 threads as default, just in case we have more than one request being handled | |||
const DEFAULT_THREAD_COUNT = 2; | |||
|
|||
type StartParameters = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a command to mention what is that type and where it will be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's of general use it should be in the ProcessManager file. Otherwise it whould be named TrRouting something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, this is for the TrRotuingProcessManager only
{ | ||
debug = false, | ||
cacheDirectoryPath, | ||
// Flag to enable the trRouting connection cache for all scenario |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to keep the comment after the param to make it clear to which entry it's related.
const port = parameters.port || Preferences.get('trRouting.port'); | ||
const cacheAllScenarios = | ||
config.trRoutingCacheAllScenarios === undefined ? false : config.trRoutingCacheAllScenarios; | ||
|
||
const params: Parameters<typeof startTrRoutingProcess>[3] = { | ||
debug: parameters.debug, | ||
cacheDirectoryPath: parameters.cacheDirectoryPath, | ||
cacheAllScenarios: cacheAllScenarios | ||
cacheAllScenarios: cacheAllScenarios, | ||
logFiles: parameters.logFiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it's a good idea of expose the logFiles setting externally. We should know what we expect here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option for this PR would be to simply put the winston config in the config.js file (maybe not exactly the config, but something tha twill allow us to easily build that config). That would avoid all the parameter passing, each service can get its log configuration and we won't have to add too much when we want to support something else than log files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated so log files are only configurable through the config, there's no use case for individually setting it.
examples/config.js
Outdated
@@ -17,6 +17,19 @@ module.exports = { | |||
|
|||
// Enable caching of connections for all scenarios in trRouting. Will use more memory | |||
trRoutingCacheAllScenarios: false, | |||
// Extra options for running trRouting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We if add a config block for trRouting, then we need to move the cacheAllFlag inside of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also move the port number there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in previous PR
Go from 3.7.2 to 3.14.2
The `startProcess` function receives 8 arguments as parameter, that's a lot and difficult to read when calling the function. Adding more arguments will only get more difficult. So we switch to named arguments instead.
Add an argument `logFiles` in the ProcessManager's `startProcess` function. This argument takes the maximum size in kilobytes of the log files and the maximum number of desired files.
406414f
to
15298ef
Compare
…eparately The `TrRoutingStartParameterss` type contains all the extra parameter of the various start functions, so this type can be re-used in all functions (`start`, `restart` and `startBatch`). All but the first argument of the `startBatch` function is now part of a unique object with named arguments, adding the `debug` parameters.
15298ef
to
bd6b6c5
Compare
@greenscientist I rebase and updated to address all your comments. With this, next time we need to investigate some trRouting related errors, we'll be ready to configure debug and logging in our instances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last question.
@@ -12,6 +12,8 @@ import serviceLocator from 'chaire-lib-common/lib/utils/ServiceLocator'; | |||
import ProcessUtils from './ProcessUtils'; | |||
|
|||
const PID_DIRECTORY = 'pids'; | |||
const DEFAULT_LOG_FILE_COUNT = 3; // 3 files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't those be removed in the last commit, now that we have default in the config file???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config is only for trRouting, this is the main process manager and applies to all possible processes to start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we combine those constant somehow? Can the trRouting default config information use those constant ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the config file
This adds a `debug` and `logs` configuration option to the TrRoutingConfig type. They can be configured on the `config.js` used in the project. `debug` is a boolean option specifying whether to start the trRouting process in debug mode `logs` configures the loggins of the trRouting process. Currently, the options that can be set are `maxFileSizeKB` for the maximum size of a log file in kilobytes and `nbFiles` to specify the number of log files to keep. They can be set separately for the batch or single instance. These onfigurations are optional. Move the default log file count and size to the config instead of the `ProcessManager.ts` file.
bd6b6c5
to
208d331
Compare
Use named objects instead of ordinal parameters for the numerous function parameters. This makes a call more readable, make it easier to fine-tune specific parameters while keeping the default values for others, and will make adding yet more parameters simpler.
Let
ProcessManager
support log file count and size as extra parameterLet
TrRoutingProcessManager
support log file count and size as extra parameter.startBatch
now also supports thedebug
option.Add tests for the new functionalities