scheduled-sync.mjs 767 B

12345678
  1. /** One maintenance run for cron/systemd; no credentials are accepted on the command line. */
  2. import { spawnSync } from 'node:child_process';
  3. import { fileURLToPath } from 'node:url';
  4. if (process.argv.length !== 2) { console.error('NO_ARGUMENTS_ALLOWED'); process.exit(1); }
  5. const key = 'wecom-identity:scheduled:' + new Date().toISOString().slice(0, 16);
  6. const result = spawnSync(process.execPath, [fileURLToPath(new URL('./manage.mjs', import.meta.url)), 'sync', '--sessions', 'all', '--apply', '--request-id', key], { encoding: 'utf8', windowsHide: true });
  7. if (result.error) { console.error('IDENTITY_SYNC_PROCESS_FAILED'); process.exit(1); }
  8. process.stdout.write(result.stdout || ''); process.stderr.write(result.stderr || ''); process.exit(result.status ?? 1);