orchestrator changes
This commit is contained in:
parent
aef8105bb0
commit
eb629835d2
849
backend/orchestrator/package-lock.json
generated
849
backend/orchestrator/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@google-cloud/container": "^5.12.0",
|
||||
"@kubernetes/client-node": "^0.21.0",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.4.5",
|
||||
|
@ -76,7 +76,7 @@ spec:
|
||||
name: <SANDBOX>
|
||||
port:
|
||||
number: 4000
|
||||
- host: <SANDBOX>.s.ishaand.com
|
||||
- host: <SANDBOX>.sandbox.ishaand.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
|
@ -12,12 +12,14 @@ import {
|
||||
NetworkingV1Api,
|
||||
} from "@kubernetes/client-node"
|
||||
import { z } from "zod"
|
||||
import container from '@google-cloud/container';
|
||||
|
||||
const app = express()
|
||||
const port = process.env.PORT || 4001
|
||||
app.use(express.json())
|
||||
dotenv.config()
|
||||
|
||||
|
||||
// const corsOptions = {
|
||||
// origin: ['http://localhost:3000', 'https://s.ishaand.com', 'http://localhost:4000', /\.ws\.ishaand\.com$/],
|
||||
// }
|
||||
@ -105,6 +107,26 @@ app.post("/test", async (req, res) => {
|
||||
app.post("/start", async (req, res) => {
|
||||
const { sandboxId } = dataSchema.parse(req.body)
|
||||
|
||||
async function main() {
|
||||
const client = new container.v1.ClusterManagerClient();
|
||||
|
||||
async function quickstart() {
|
||||
const zone = 'us-central1-a';
|
||||
const projectId = await client.getProjectId();
|
||||
const request = {
|
||||
projectId: projectId,
|
||||
zone: zone,
|
||||
};
|
||||
|
||||
const [response] = await client.listClusters(request);
|
||||
console.log('Clusters: ', response);
|
||||
}
|
||||
|
||||
quickstart();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
try {
|
||||
|
||||
console.log("Creating resources for sandbox", sandboxId)
|
||||
|
@ -418,6 +418,7 @@ io.on("connection", async (socket) => {
|
||||
)
|
||||
|
||||
socket.on("disconnect", async () => {
|
||||
console.log("disconnected", data.userId, data.sandboxId)
|
||||
if (data.isOwner) {
|
||||
// console.log("deleting all terminals")
|
||||
Object.entries(terminals).forEach((t) => {
|
||||
@ -445,11 +446,13 @@ io.on("connection", async (socket) => {
|
||||
}
|
||||
});
|
||||
}, 20000);
|
||||
} else {
|
||||
console.log("number of sockets", sockets.length)
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
httpServer.listen(port, () => {
|
||||
console.log(`Server running on port ${port}`)
|
||||
console.log(`Server, running on port ${port}`)
|
||||
})
|
||||
|
@ -198,7 +198,7 @@ ${code}`,
|
||||
}
|
||||
|
||||
export const stopServer = async (sandboxId: string, userId: string) => {
|
||||
const res = await fetch("http://localhost:4001/stop", {
|
||||
const res = await fetch("https://sylvan-epoch-422219-f9.uc.r.appspot.com/stop", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
@ -52,7 +52,7 @@ export function addNew(name: string, type: "file" | "folder", setFiles: React.Di
|
||||
|
||||
export async function startServer(sandboxId: string, userId: string, callback: (success: boolean) => void) {
|
||||
try {
|
||||
const res = await fetch("http://localhost:4001/start", {
|
||||
const res = await fetch("https://sylvan-epoch-422219-f9.uc.r.appspot.com/start", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
Loading…
x
Reference in New Issue
Block a user