Skip to content

Commit

Permalink
version bump, final kick agent scenario fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorJTClarke committed Feb 3, 2022
1 parent 6bfd25d commit 5cae1a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "croncat",
"version": "1.6.5",
"version": "1.7.0",
"description": "cron.cat CLI and Agent Runner",
"main": "src/index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export const currentStatus = () => {
return agentSettings.status || 'Pending'
}

export const settings = () => {
return agentSettings || {}
}

// returns if agent is active or not
export const checkStatus = async () => {
let isActive = false
Expand Down
13 changes: 8 additions & 5 deletions src/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,20 @@ export const proxyCall = async () => {
return skipThisIteration
}

let agentSettings = {}
export async function run() {
let skipThisIteration = false
let previousAgentSettings = { ...agentSettings }
agentSettings = agent.settings()

// 1. Check for tasks
skipThisIteration = await getTasks()
if (skipThisIteration) return setTimeout(run, config.WAIT_INTERVAL_MS)

// 2. Check agent status
// TODO: Change - to only check if KICKED, needs to store local agent state
// skipThisIteration = await checkAgent()
// if (skipThisIteration) return setTimeout(run, config.WAIT_INTERVAL_MS)
// 2. Check agent kicked, if so, stop the loop until auto-reregister kicks in
if (
previousAgentSettings && previousAgentSettings.status === 'Active' &&
agentSettings && !agentSettings.status
) skipThisIteration = true

// 3. Sign task and submit to chain
if (!skipThisIteration) skipThisIteration = await proxyCall()
Expand Down
1 change: 0 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ let cronManager = null

export async function connect(options) {
try {
// TODO: options
await Near.getNearConnection(options)
} catch (e) {
log(`${chalk.red('NEAR Connection Failed')}`)
Expand Down

0 comments on commit 5cae1a4

Please sign in to comment.