Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
matyson committed Sep 30, 2024
1 parent 1df04f5 commit 13d5a7c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
4 changes: 0 additions & 4 deletions src/server/api/routers/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export const jobRouter = createTRPCRouter({
const command = `sacct --job ${jobId}.batch --format=State --parsable2`;
const { stdout, stderr } = await connection.execCommand(command);


if (stderr) {
throw new Error(stderr);
}
Expand Down Expand Up @@ -132,7 +131,6 @@ export const jobRouter = createTRPCRouter({
const command = `scancel ${jobId}`;
const { stderr } = await connection.execCommand(command);


if (stderr) {
throw new Error(stderr);
}
Expand All @@ -153,8 +151,6 @@ export const jobRouter = createTRPCRouter({
const command = `sacct --format="State,Submit,Start,End,Elapsed,Partition,NodeList,AllocGRES,NCPUS,Reason,ExitCode" --parsable2 --job ${jobId} --noheader`;
const { stdout, stderr } = await connection.execCommand(command);



if (stderr) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
Expand Down
1 change: 0 additions & 1 deletion src/server/api/routers/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const sshRouter = createTRPCRouter({
const command = `ls -pm --group-directories-first ${input.path}`;
const { stdout, stderr } = await connection.execCommand(command);


if (stderr) {
const error = z
.object({
Expand Down
6 changes: 5 additions & 1 deletion src/server/api/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export const protectedProcedureWithCredentials = t.procedure.use(
const res = await next({
ctx: {
// infers the `session` as non-nullable
session: { ...ctx.session, credentials: { name: username, keys }, connection },
session: {
...ctx.session,
credentials: { name: username, keys },
connection,
},
},
});

Expand Down
62 changes: 31 additions & 31 deletions src/server/ssh/sesh.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import type { NodeSSH } from "node-ssh"
import type { NodeSSH } from "node-ssh";
// a storage-unbounded ttl cache that is not an lru-cache
export const cache = {
data: new Map<PropertyKey, NodeSSH>(),
timers: new Map<PropertyKey, ReturnType<typeof setTimeout>>(),
set: (k: PropertyKey, v: NodeSSH, ttl: number) => {
if (cache.timers.has(k)) {
clearTimeout(cache.timers.get(k))
}
cache.timers.set(
k,
setTimeout(() => cache.delete(k), ttl)
)
cache.data.set(k, v)
},
get: (k: PropertyKey) => cache.data.get(k),
has: (k: PropertyKey) => cache.data.has(k),
delete: (k: PropertyKey) => {
if (cache.timers.has(k)) {
clearTimeout(cache.timers.get(k))
}
cache.timers.delete(k)
cache.data.get(k)?.dispose()
return cache.data.delete(k)
},
clear: () => {
cache.data.clear()
for (const v of cache.timers.values()) {
clearTimeout(v)
}
cache.timers.clear()
},
}
data: new Map<PropertyKey, NodeSSH>(),
timers: new Map<PropertyKey, ReturnType<typeof setTimeout>>(),
set: (k: PropertyKey, v: NodeSSH, ttl: number) => {
if (cache.timers.has(k)) {
clearTimeout(cache.timers.get(k));
}
cache.timers.set(
k,
setTimeout(() => cache.delete(k), ttl),
);
cache.data.set(k, v);
},
get: (k: PropertyKey) => cache.data.get(k),
has: (k: PropertyKey) => cache.data.has(k),
delete: (k: PropertyKey) => {
if (cache.timers.has(k)) {
clearTimeout(cache.timers.get(k));
}
cache.timers.delete(k);
cache.data.get(k)?.dispose();
return cache.data.delete(k);
},
clear: () => {
cache.data.clear();
for (const v of cache.timers.values()) {
clearTimeout(v);
}
cache.timers.clear();
},
};

0 comments on commit 13d5a7c

Please sign in to comment.