tangled
alpha
login
or
join now
rocksky.app
/
rocksky
96
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
96
fork
atom
overview
issues
7
pulls
pipelines
Merge branch 'main' into feat/feed-generator
tsiry-sandratraina.com
4 months ago
4a1d702a
7e87cd93
+76
-1
4 changed files
expand all
collapse all
unified
split
package.json
tools
cron.ts
deno.json
deno.lock
+2
-1
package.json
···
29
29
"db:pgpull": "cargo run -p rockskyd --release -- pull && rm -f rocksky-analytics.ddb* rocksky-feed.ddb* && curl -o rocksky-analytics.ddb https://backup.rocksky.app/rocksky-analytics.ddb && curl -o rocksky-feed.ddb https://backup.rocksky.app/rocksky-feed.ddb",
30
30
"mb": "cd musicbrainz && go run main.go",
31
31
"spotify": "cd apps/api && bun run spotify",
32
32
-
"build:raichu": "cd crates/raichu && wasm-pack build --release --target web && cp -r pkg ../../apps/web/src"
32
32
+
"build:raichu": "cd crates/raichu && wasm-pack build --release --target web && cp -r pkg ../../apps/web/src",
33
33
+
"cron": "tools/cron.ts"
33
34
},
34
35
"workspaces": [
35
36
"apps/api",
+35
tools/cron.ts
···
1
1
+
#!/usr/bin/env -S deno run --unstable-cron -A
2
2
+
3
3
+
/// <reference lib="deno.ns" />
4
4
+
/// <reference lib="dom" />
5
5
+
6
6
+
import chalk from "chalk";
7
7
+
8
8
+
const args = Deno.args;
9
9
+
10
10
+
if (args.length < 2) {
11
11
+
console.log(
12
12
+
chalk.greenBright("Usage: cron <interval-in-minutes> <command> [args...]")
13
13
+
);
14
14
+
Deno.exit(0);
15
15
+
}
16
16
+
17
17
+
const interval = parseInt(args[0], 10);
18
18
+
if (Number.isNaN(interval) || interval <= 0) {
19
19
+
console.error("Interval must be a positive integer");
20
20
+
Deno.exit(1);
21
21
+
}
22
22
+
23
23
+
Deno.cron("cron", { minute: { every: interval } }, async () => {
24
24
+
const command = new Deno.Command(args[1], {
25
25
+
args: args.slice(2),
26
26
+
stdout: "inherit",
27
27
+
stderr: "inherit",
28
28
+
});
29
29
+
const child = command.spawn();
30
30
+
const status = await child.status;
31
31
+
if (!status.success) {
32
32
+
console.error(`Cron job failed with code ${status.code}`);
33
33
+
}
34
34
+
console.log(`Cron job executed at ${new Date().toISOString()}`);
35
35
+
});
+9
tools/deno.json
···
1
1
+
{
2
2
+
"tasks": {
3
3
+
"cron": "deno run cron.ts"
4
4
+
},
5
5
+
"imports": {
6
6
+
"@std/assert": "jsr:@std/assert@1",
7
7
+
"chalk": "npm:chalk@^5.6.2"
8
8
+
}
9
9
+
}
+30
tools/deno.lock
···
1
1
+
{
2
2
+
"version": "5",
3
3
+
"specifiers": {
4
4
+
"jsr:@std/assert@1": "1.0.15",
5
5
+
"jsr:@std/internal@^1.0.12": "1.0.12",
6
6
+
"npm:chalk@^5.6.2": "5.6.2"
7
7
+
},
8
8
+
"jsr": {
9
9
+
"@std/assert@1.0.15": {
10
10
+
"integrity": "d64018e951dbdfab9777335ecdb000c0b4e3df036984083be219ce5941e4703b",
11
11
+
"dependencies": [
12
12
+
"jsr:@std/internal"
13
13
+
]
14
14
+
},
15
15
+
"@std/internal@1.0.12": {
16
16
+
"integrity": "972a634fd5bc34b242024402972cd5143eac68d8dffaca5eaa4dba30ce17b027"
17
17
+
}
18
18
+
},
19
19
+
"npm": {
20
20
+
"chalk@5.6.2": {
21
21
+
"integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="
22
22
+
}
23
23
+
},
24
24
+
"workspace": {
25
25
+
"dependencies": [
26
26
+
"jsr:@std/assert@1",
27
27
+
"npm:chalk@^5.6.2"
28
28
+
]
29
29
+
}
30
30
+
}