Skip to content

Commit

Permalink
Set up the sim env
Browse files Browse the repository at this point in the history
  • Loading branch information
lilsweetcaligula committed Aug 29, 2021
1 parent a4d94a4 commit 9284bed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 3 additions & 1 deletion env/sim/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ fi

# Setting up frontend
#
./env/sim/scripts/frontend-start.sh
if ! curl "${LOCALHOST}:8080" -s >& /dev/null; then
./env/sim/scripts/frontend-start.sh
fi

2 changes: 1 addition & 1 deletion env/sim/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ seneca.ready(() => {

// NOTE: Scheduling the tasks.
//
//TasksCollection.run({ seneca })
TasksCollection.run({ seneca })
})

21 changes: 15 additions & 6 deletions env/sim/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function run({ seneca }) {

function download_pkgs_names({ seneca }) {
return schedule_once(() => {
console.dir(`download_pkgs_names, triggered at ${new Date()}`)
seneca.act('role:update,start:download,all:true')
})
}
Expand All @@ -36,10 +37,12 @@ function fulfill_pkgs_downloads({ seneca }) {


function pull_npm_history({ seneca }) {
const started_at = new Date()
const now = new Date()

const started_at = Moment(now).add(2, 'minutes').toDate()
const started_at_hrs = started_at.getHours()
const started_at_mins = 1 + started_at.getMinutes()
const started_at_mins = started_at.getMinutes()

const scheduled_daily = `${started_at_mins} ${started_at_hrs} * * *`

return Cron.schedule(scheduled_daily, async () => {
Expand All @@ -51,6 +54,8 @@ function pull_npm_history({ seneca }) {
const pkgs = await seneca.make('nodezoo', 'npm')
.list$({ all$: true, fields$: ['name'] })

console.dir(`pull_npm_history, located ${pkgs.length} packages`)


for (let i = 0; i < pkgs.length; i++) {
const pkg = pkgs[i]
Expand All @@ -75,8 +80,7 @@ function pull_npm_history({ seneca }) {
}
}
}, {
scheduled: true,
timezone: 'UTC'
scheduled: true
})
}

Expand All @@ -91,10 +95,12 @@ function pull_github_history({ seneca }) {
const iter_sleep_ms = Math.ceil(MS_IN_HOUR / GITHUB_HOURLY_RATE_LIMIT)


const started_at = new Date()
const now = new Date()

const started_at = Moment(now).add(2, 'minutes').toDate()
const started_at_hrs = started_at.getHours()
const started_at_mins = 1 + started_at.getMinutes()
const started_at_mins = started_at.getMinutes()

const scheduled_daily = `${started_at_mins} ${started_at_hrs} * * *`

return Cron.schedule(scheduled_daily, async () => {
Expand All @@ -104,6 +110,9 @@ function pull_github_history({ seneca }) {
const pkgs = await seneca.make('nodezoo', 'npm')
.list$({ all$: true, fields$: ['name'] })

console.dir(`pull_npm_history, located ${pkgs.length} packages`)


for (let i = 0; i < pkgs.length; i++) {
if (GITHUB_HOURLY_RATE_LIMIT <= i) {
const now = new Date()
Expand Down

0 comments on commit 9284bed

Please sign in to comment.