Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/controllers/agent-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const deleteNodeEndPoint = async function (req, fog) {
return await AgentService.deleteNode(fog);
};

const getImageSnapshotEndPoint = async function(req, fog) {
const getImageSnapshotEndPoint = async function (req, fog) {
return await AgentService.getImageSnapshot(fog);
};

Expand Down
6 changes: 6 additions & 0 deletions src/decorators/authorization-decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ function checkFogToken(f) {
}

fArgs.push(fog);

FogAccessTokenManager.updateExpirationTime(fog.accessToken.id, fog.accessToken.expirationTime + config.get('Settings:FogTokenExpirationIntervalSeconds') * 1000);

const timestamp = Date.now();
logger.info('updating agent lastActive timestamp: ' + timestamp);
await FogManager.updateLastActive(fog.uuid, timestamp);

return await f.apply(this, fArgs);
}
}
Expand Down
28 changes: 21 additions & 7 deletions src/sequelize/managers/iofog-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
*
*/

const BaseManager = require('../managers/base-manager')
const BaseManager = require('../managers/base-manager');
const models = require('./../models');
const Fog = models.Fog
const Microservice = models.Microservice
const FogAccessToken = models.FogAccessToken
const Strace = models.StraceDiagnostics
const Fog = models.Fog;
const Microservice = models.Microservice;
const FogAccessToken = models.FogAccessToken;
const Strace = models.StraceDiagnostics;

class FogManager extends BaseManager {
getEntity() {
Expand All @@ -36,6 +36,18 @@ class FogManager extends BaseManager {
});
}


// no transaction required here, used by agent-last-active decorator
updateLastActive(uuid, timestamp) {
return Fog.update({
lastActive: timestamp
}, {
where: {
uuid: uuid
}
});
}

findFogStraces(where, transaction) {
return Fog.findOne({
include: [
Expand All @@ -52,7 +64,9 @@ class FogManager extends BaseManager {
where: where
}, {transaction: transaction})
}


}

const instance = new FogManager()
module.exports = instance
const instance = new FogManager();
module.exports = instance;