summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2021-01-25 19:36:41 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2021-01-27 15:24:02 +0100
commit2f8a83288d91ea0abc2e4ebd6754513ee3ad37ec (patch)
tree6483d7126ee5b0f5fca1fd8ed100188e953dc6be
parent4d9f922c8396bada73fb0b1e318c8b947f0f606b (diff)
README: add an example script to reuse the sfeed_update code
This code uses the non-portable xargs -P option to more efficiently process feeds in parallel.
-rw-r--r--README43
1 files changed, 43 insertions, 0 deletions
diff --git a/README b/README
index bce200a..e36374b 100644
--- a/README
+++ b/README
@@ -626,6 +626,49 @@ sfeedrc file and change the curl options "-L --max-redirs 0".
- - -
+Shellscript to update feeds in parallel more efficiently using xargs -P.
+
+It creates a queue of the feeds with its settings, then uses xargs to process
+them in parallel using the common, but non-POSIX -P option. This is more
+efficient than the more portable solution in sfeed_update which can stall a
+batch of $maxjobs in the queue if one item is slow.
+
+sfeed_update_xargs shellscript:
+
+ #!/bin/sh
+ # update feeds, merge with old feeds using xargs in parallel mode (non-POSIX).
+
+ # include script and reuse its functions, but do not start main().
+ SFEED_UPDATE_INCLUDE="1" . sfeed_update
+ # load config file, sets $config.
+ loadconfig "$1"
+
+ # process a single feed.
+ # args are: config, tmpdir, name, feedurl, basesiteurl, encoding
+ if [ "${SFEED_UPDATE_CHILD}" != "" ]; then
+ sfeedtmpdir="$2"
+ _feed "$3" "$4" "$5" "$6"
+ exit $?
+ fi
+
+ # ...else parent mode:
+
+ # feed(name, feedurl, basesiteurl, encoding)
+ feed() {
+ printf '%s\0%s\0%s\0%s\0%s\0%s\0' "${config}" "${sfeedtmpdir}" "$1" "$2" "$3" "$4"
+ }
+
+ # fetch feeds and store in temporary directory.
+ sfeedtmpdir="$(mktemp -d '/tmp/sfeed_XXXXXX')"
+ # make sure path exists.
+ mkdir -p "${sfeedpath}"
+ # print feeds for parallel processing with xargs.
+ feeds | SFEED_UPDATE_CHILD="1" xargs -0 -P "${maxjobs}" -L 6 "$(readlink -f "$0")"
+ # cleanup temporary files etc.
+ cleanup
+
+- - -
+
Shellscript to export existing newsboat cached items from sqlite3 to the sfeed
TSV format.