Skip to content

Instantly share code, notes, and snippets.

@Bestulo
Created October 28, 2022 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bestulo/016d8464f70172afe0592147cd50a13b to your computer and use it in GitHub Desktop.
Save Bestulo/016d8464f70172afe0592147cd50a13b to your computer and use it in GitHub Desktop.
restart capy
import { Application } from "https://deno.land/x/oak@v11.1.0/mod.ts";
const app = new Application();
app.use((ctx) => {
// if receive request to /restart?bot=capy, use `pm2 restart capy`
if (
ctx.request.url.pathname === "/restart" &&
ctx.request.url.searchParams.get("bot") === "capy"
) {
Deno.run({ cmd: ["pm2", "restart", "capy"] });
ctx.response.body = "Restarted capy";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment