Compare commits
4 Commits
00e035c853
...
7aa64cfdaa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7aa64cfdaa | ||
|
|
489e023494 | ||
|
|
7635dfc124 | ||
|
|
75fca493e5 |
|
|
@ -4,6 +4,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"runner": "bun run src/runner.ts",
|
||||||
"start": "bun src/server.tsx",
|
"start": "bun src/server.tsx",
|
||||||
"prod": "env NODE_ENV=production bun src/server.tsx",
|
"prod": "env NODE_ENV=production bun src/server.tsx",
|
||||||
"dev": "env BUN_HOT=1 bun --hot src/server.tsx",
|
"dev": "env BUN_HOT=1 bun --hot src/server.tsx",
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,9 @@ ROOT_DIR="$SCRIPT_DIR/../.."
|
||||||
# Run deploy + config with absolute paths
|
# Run deploy + config with absolute paths
|
||||||
source "$ROOT_DIR/app/scripts/config.sh"
|
source "$ROOT_DIR/app/scripts/config.sh"
|
||||||
|
|
||||||
|
# Make sure we're up-to-date
|
||||||
|
git push origin main
|
||||||
|
git push gitea main
|
||||||
|
|
||||||
# Run remote install on the target
|
# Run remote install on the target
|
||||||
ssh $HOST "cd $DEST && git pull && bun install && sudo systemctl restart nose-pluto.service"
|
ssh $HOST "cd $DEST && bun runner update"
|
||||||
28
app/src/runner.ts
Normal file
28
app/src/runner.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
////
|
||||||
|
// Runs a NOSE command in the NOSE environment
|
||||||
|
// Ex:
|
||||||
|
// $ bun runner greet Bob
|
||||||
|
// Hi, Bob!
|
||||||
|
|
||||||
|
import { runCommand } from "./shell"
|
||||||
|
|
||||||
|
const args = Bun.argv.slice(2)
|
||||||
|
|
||||||
|
if (!args.length) {
|
||||||
|
console.error("usage: runner <command> [args]")
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sessionId = ""
|
||||||
|
const taskId = ""
|
||||||
|
|
||||||
|
const result = await runCommand(sessionId, taskId, args.join(" "))
|
||||||
|
|
||||||
|
if (result.status === "ok")
|
||||||
|
console.log(result.output)
|
||||||
|
|
||||||
|
else if (result.status === "error")
|
||||||
|
console.error(result.output)
|
||||||
|
|
||||||
|
else
|
||||||
|
console.error("Unknown command result:", result)
|
||||||
|
|
@ -11,7 +11,7 @@ import { ALS } from "./session"
|
||||||
|
|
||||||
const sessions: Map<string, Session> = new Map()
|
const sessions: Map<string, Session> = new Map()
|
||||||
|
|
||||||
export async function runCommand(session: string, id: string, input: string): Promise<CommandResult> {
|
export async function runCommand(sessionId: string, taskId: string, input: string): Promise<CommandResult> {
|
||||||
const [cmd = "", ...args] = input.split(" ")
|
const [cmd = "", ...args] = input.split(" ")
|
||||||
|
|
||||||
if (!commandExists(cmd)) {
|
if (!commandExists(cmd)) {
|
||||||
|
|
@ -20,7 +20,7 @@ export async function runCommand(session: string, id: string, input: string): Pr
|
||||||
|
|
||||||
let status: "ok" | "error" = "ok"
|
let status: "ok" | "error" = "ok"
|
||||||
let output: CommandOutput = ""
|
let output: CommandOutput = ""
|
||||||
const state = getState(session, id)
|
const state = getState(sessionId, taskId)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
[status, output] = await ALS.run(state, async () => await exec(cmd, args))
|
[status, output] = await ALS.run(state, async () => await exec(cmd, args))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user