fix: log when registration is published to

This commit is contained in:
Alexis Tyler
2021-04-23 08:57:58 +09:30
parent f52d85ca42
commit 7d3e168576
2 changed files with 14 additions and 15 deletions
+1 -3
View File
@@ -83,9 +83,7 @@ type RegistrationState =
'EBLACKLISTED' |
'EBLACKLISTED1' |
'EBLACKLISTED2' |
'ENOCONN' |
/** Everything is fine. */
'';
'ENOCONN';
interface VarIni {
bindMgt: IniStringBooleanOrAuto;
+13 -12
View File
@@ -5,7 +5,7 @@
import { dirname } from 'path';
import chokidar from 'chokidar';
import { coreLogger } from '../log';
import { coreLogger, logger } from '../log';
import { varState } from '../states';
import { pubsub } from '../pubsub';
import { getKeyFile } from '../utils';
@@ -39,20 +39,21 @@ export const keyFile = () => {
// Get key file
const keyFile = await getKeyFile();
const registration = {
guid: varState.data.regGuid,
type: varState.data.regTy.toUpperCase(),
state: varState.data.regState,
keyFile: {
location: fullPath,
contents: keyFile
}
};
logger.debug('Publishing %s to registration', JSON.stringify(registration, null, 2));
// Publish event
// This will end up going to the graphql endpoint
await pubsub.publish('registration', {
registration: {
guid: varState.data.regGuid,
type: varState.data.regTy.toUpperCase(),
state: varState.data.regState,
keyFile: {
location: fullPath,
contents: keyFile
}
}
}).catch(error => {
await pubsub.publish('registration', registration).catch(error => {
coreLogger.error('Failed publishing to "registration" with %s', error);
});