Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contract/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resolution = true
skip-lint = false

[programs.localnet]
contract = "J7nyNjMR7p9Xi8ohzkNAFmnAeVUBb1AMpGKTFGtFvVjJ"
contract = "BD8qpWm9WWLcqQu5PKJ3Lew4BZ6nh6n96FMZv3DJ54sc"

[registry]
url = "https://api.apr.dev"
Expand Down
2 changes: 1 addition & 1 deletion contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Anchor framework program managing VM rental sessions, escrow payments, and DePIN host registration.

**Program ID (devnet):** `J7nyNjMR7p9Xi8ohzkNAFmnAeVUBb1AMpGKTFGtFvVjJ`
**Program ID (devnet):** `BD8qpWm9WWLcqQu5PKJ3Lew4BZ6nh6n96FMZv3DJ54sc`

## Instructions

Expand Down
2 changes: 1 addition & 1 deletion contract/programs/contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod depin;
use instructions::*;
use depin::*;

declare_id!("J7nyNjMR7p9Xi8ohzkNAFmnAeVUBb1AMpGKTFGtFvVjJ");
declare_id!("BD8qpWm9WWLcqQu5PKJ3Lew4BZ6nh6n96FMZv3DJ54sc");

#[program]
pub mod contract {
Expand Down
2 changes: 1 addition & 1 deletion indexer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Config {
grpc_endpoint: env::var("GRPC_ENDPOINT")
.unwrap_or_else(|_| "http://127.0.0.1:10000".to_string()),
program_id: env::var("PROGRAM_ID")
.unwrap_or_else(|_| "J7nyNjMR7p9Xi8ohzkNAFmnAeVUBb1AMpGKTFGtFvVjJ".to_string()),
.unwrap_or_else(|_| "BD8qpWm9WWLcqQu5PKJ3Lew4BZ6nh6n96FMZv3DJ54sc".to_string()),
backend_webhook_url: env::var("BACKEND_WEBHOOK_URL")
.unwrap_or_else(|_| "http://localhost:3000/api/v2/indexer/webhook".to_string()),
ws_relayer_url: env::var("WS_RELAYER_URL")
Expand Down
86 changes: 85 additions & 1 deletion ops/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ spec:
image: krishanand01/axion-frontend:v1.2.11
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
resources:
requests:
cpu: "5m"
Expand Down Expand Up @@ -68,6 +82,20 @@ spec:
image: krishanand01/axion-backend:v1.2.11
ports:
- containerPort: 3000
livenessProbe:
httpGet:
path: /api/v2/health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /api/v2/health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
resources:
requests:
cpu: "5m"
Expand Down Expand Up @@ -159,13 +187,29 @@ spec:
containers:
- name: axion-worker
image: krishanand01/axion-worker:v1.2.11
ports:
- containerPort: 9094
livenessProbe:
httpGet:
path: /health
port: 9094
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 9094
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
resources:
requests:
cpu: "5m"
memory: "32Mi"
limits:
cpu: "100m"
memory: "512Mi"
memory: "1Gi"
volumeMounts:
- name: env-file
mountPath: /app/apps/worker/.env
Expand Down Expand Up @@ -208,6 +252,20 @@ spec:
image: krishanand01/axion-ws-relayer:v1.2.11
ports:
- containerPort: 9093
livenessProbe:
httpGet:
path: /health
port: 9093
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 9093
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
resources:
requests:
cpu: "5m"
Expand Down Expand Up @@ -252,6 +310,20 @@ spec:
image: krishanand01/axion-depin-ws-relayer:v1.2.11
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
resources:
requests:
cpu: "5m"
Expand Down Expand Up @@ -289,6 +361,18 @@ spec:
image: redis:7-alpine
ports:
- containerPort: 6379
livenessProbe:
tcpSocket:
port: 6379
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
readinessProbe:
tcpSocket:
port: 6379
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
volumeMounts:
- name: redis-data
mountPath: /data
Expand Down
34 changes: 30 additions & 4 deletions web-services/apps/backend/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from "express";
import cors from "cors";
import type { NextFunction, Request, Response } from "express";
import type { Server } from "http";
import { sendError, logger } from "@axion/utilities";
import { redisConnection } from "@axion/utilities/redis";
import {
Expand All @@ -9,6 +10,9 @@ import {
indexerLimiter,
healthLimiter,
depinVerificationLimiter,
deployLimiter,
registerLimiter,
claimSOLLimiter,
} from "@axion/utilities/rateLimiter";
import prisma from "@axion/db";
import UserRouter from "./routes/user";
Expand Down Expand Up @@ -36,12 +40,16 @@ app.use(cors());

app.use("/api/v2/user/signup", publicLimiter);
app.use("/api/v2/user/login", publicLimiter);
app.use("/api/v2/user/depin/depinVerification", depinVerificationLimiter);
app.use("/api/v2/indexer", indexerLimiter);
app.use("/api/v2/user", authLimiter);
app.use("/api/v2/user/me", authLimiter);
app.use("/api/v2/user/checkTimeout", authLimiter);
app.use("/api/v2/vmInstance", authLimiter);
app.use("/api/v2/vm", authLimiter);
app.use("/api/v2/user/depin", authLimiter);
app.use("/api/v2/user/depin/depinVerification", depinVerificationLimiter);
app.use("/api/v2/user/depin/deploy", deployLimiter);
app.use("/api/v2/user/depin/register", registerLimiter);
app.use("/api/v2/user/depin/claimSOL", claimSOLLimiter);
app.use("/api/v2/indexer", indexerLimiter);

app.use("/api/v2/user", UserRouter);
app.use("/api/v2/vmInstance", vmInstance);
Expand Down Expand Up @@ -83,6 +91,24 @@ app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
sendError(res, err);
});

app.listen(3000, () => {
const server: Server = app.listen(3000, () => {
logger.info("Backend server started", { port: 3000 });
});

function gracefulShutdown(signal: string) {
logger.info(`Received ${signal}, shutting down gracefully...`);
server.close(() => {
logger.info("HTTP server closed");
prisma.$disconnect().finally(() => {
redisConnection.quit();
process.exit(0);
});
});
setTimeout(() => {
logger.error("Forced shutdown after timeout");
process.exit(1);
}, 10_000);
}

process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
process.on("SIGINT", () => gracefulShutdown("SIGINT"));
Loading
Loading