Skip to content

Commit

Permalink
Added minor updates to configs, rpc and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorJTClarke committed Nov 22, 2021
1 parent e2b6397 commit fcd6116
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
19 changes: 17 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ NODE_ENV=production
NEAR_ENV=mainnet

LOG_LEVEL=info
BETA_FEATURES=false
NEAR_NO_LOGS=true

AGENT_ACCOUNT_ID=croncat-agent
AGENT_ACCOUNT_ID=croncat-agent.near
AGENT_MIN_TASK_BALANCE=1
#NOTE: This is really only useful if the payout account is the same as the agent account
AGENT_AUTO_REFILL=false

# Period between executing standard tasks, needs to be less than 60 seconds to be effective
WAIT_INTERVAL_MS=25000

# Period to check if a trigger needs executing, you should use a semi-fast value that doesnt break your RPC service.
VIEW_INTERVAL_MS=2000

## Extras
SLACK_TOKEN=
SLACK_CHANNEL=general

# If you have an external heartbeat service that just needs a ping
HEARTBEAT=false
HEARTBEAT_URL=
HEARTBEAT_URL=

## -------------------------------------------------------------------
## RPC Providers
## Configure the following as CSV, in priority order, for RPC Failover
## -------------------------------------------------------------------
# Example: RPC_MAINNET_PROVIDERS="https://rpc.mainnet.near.org,http://localhost:3030"
RPC_MAINNET_PROVIDERS="https://rpc.mainnet.near.org"
RPC_TESTNET_PROVIDERS="https://rpc.testnet.near.org"
RPC_GUILDNET_PROVIDERS="https://rpc.openshards.io"
RPC_BETANET_PROVIDERS="https://rpc.betanet.near.org"
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.5.1",
"version": "1.5.2",
"description": "cron.cat CLI and Agent Runner",
"main": "src/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export async function runAgentTick(options = {}) {
}
totalTasks = parseInt(taskRes[0])
if (taskRes[1] === '0') log(`${chalk.gray(new Date().toISOString())} Available Tasks: ${chalk.red(totalTasks)}, Current Slot: ${chalk.red('Paused')}`)
else log(`${chalk.gray(new Date().toISOString())} Available Tasks: ${chalk.blueBright(totalTasks)}, Current Slot: ${chalk.yellow(taskRes[1])}`)
else log(`${chalk.gray(new Date().toISOString())} ${chalk.gray('[' + options.networkId.toUpperCase() + ']')} Available Tasks: ${chalk.blueBright(totalTasks)}, Current Slot: ${chalk.yellow(taskRes[1])}`)

if (LOG_LEVEL === 'debug') console.log('taskRes', taskRes)
if (totalTasks <= 0) skipThisIteration = true
Expand Down
16 changes: 16 additions & 0 deletions src/configuration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
require('dotenv').config()

export const RPC_MAINNET = process.env.RPC_MAINNET_PROVIDERS ? process.env.RPC_MAINNET_PROVIDERS.split(',') : 'https://rpc.mainnet.near.org'
export const RPC_TESTNET = process.env.RPC_TESTNET_PROVIDERS ? process.env.RPC_TESTNET_PROVIDERS.split(',') : 'https://rpc.testnet.near.org'
export const RPC_GUILDNET = process.env.RPC_GUILDNET_PROVIDERS ? process.env.RPC_GUILDNET_PROVIDERS.split(',') : 'https://rpc.openshards.io'
export const RPC_BETANET = process.env.RPC_BETANET_PROVIDERS ? process.env.RPC_BETANET_PROVIDERS.split(',') : 'https://rpc.betanet.near.org'

const failoverRpcs = {
mainnet: RPC_MAINNET,
testnet: RPC_TESTNET,
guildnet: RPC_GUILDNET,
betanet: RPC_BETANET,
}

function getConfigByType(networkId, config) {
return {
// Cache of available RPC nodes for failover
// rpcNodes: failoverRpcs[networkId] || [],
networkId,
nodeUrl: networkId !== 'guildnet' ? `https://rpc.${networkId}.near.org` : 'https://rpc.openshards.io',
explorerUrl: `https://explorer.${networkId === 'mainnet' ? '' : networkId + '.'}near.org`,
Expand Down

0 comments on commit fcd6116

Please sign in to comment.