Skip to content

Commit

Permalink
Add functions.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
phillmac committed May 26, 2021
1 parent 4ac6379 commit d121d3a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

function serveQueue() {
local queue_item

while read -r queue_item
do
echo -e "HTTP/1.1 200 OK\n\n ${queue_item})" | ncat -l -p 1500
done < <(
while :
do
node src/stale.js
sleep 1
done
)
}


function runWorker () {
local fetched_item
local fetch_url

fetch_url="${1:-FETCH_URL}"

if [[ -z "${fetch_url}" ]]; then
echo "FETCH_URL cannot be empty" >&2
return 252
fi

node src/scrape-cli.js --hashes-stdin-ln < <(
while read -r fetched_item
do
[[ -n "${fetched_item}" ]] && echo "${fetched_item}"
done < <(
while :
do
curl --silent "${fetch_url}"
sleep 1
done
)
)

}

0 comments on commit d121d3a

Please sign in to comment.