Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/hub/run/maintenance-syncstrings.js
Views: 687
#!/usr/bin/env node1/*2Moving patches from non-recently-used syncstrings to blobs.3*/45const postgres = require("@cocalc/database");67const db = postgres.db({ ensure_exists: false });89let {10WAIT_BETWEEN_RUNS_S,11MAX_SYNCSTRINGS_PER_RUN,12SYNCSTRINGS_AT_ONCE,13MIN_AGE_DAYS,14DELAY_MS,15} = process.env;1617if (WAIT_BETWEEN_RUNS_S == null) {18WAIT_BETWEEN_RUNS_S = "30";19}20if (MAX_SYNCSTRINGS_PER_RUN == null) {21MAX_SYNCSTRINGS_PER_RUN = "100";22}23if (SYNCSTRINGS_AT_ONCE == null) {24SYNCSTRINGS_AT_ONCE = "1";25}26if (MIN_AGE_DAYS == null) {27MIN_AGE_DAYS = "60.5";28}29if (DELAY_MS == null) {30DELAY_MS = "5000";31}3233function syncstring_maintenance(cb) {34console.log(35`syncstring_maintenance: moving patches for up to ${MAX_SYNCSTRINGS_PER_RUN} syncstrings at least ${MIN_AGE_DAYS} days old to compressed blobs...`36);37db.syncstring_maintenance({38limit: parseInt(MAX_SYNCSTRINGS_PER_RUN),39map_limit: parseInt(SYNCSTRINGS_AT_ONCE),40age_days: parseFloat(MIN_AGE_DAYS),41delay: parseInt(DELAY_MS),42repeat_until_done: false,43cb,44});45}4647function go() {48console.log("go");49syncstring_maintenance(function (err) {50if (err) {51throw Error(`error in syncstring_maintenance -- ${err}`);52}53console.log(54`now waiting ${WAIT_BETWEEN_RUNS_S} seconds before doing another syncstring_maintenance...`55);56setTimeout(go, parseInt(WAIT_BETWEEN_RUNS_S) * 1000);57});58}5960go();616263