Skip to content

Commit 02a58db

Browse files
refactor(infra): standardize service execution and optimize build pipeline
1 parent fbbb3ce commit 02a58db

File tree

6 files changed

+40
-25
lines changed

6 files changed

+40
-25
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ help:
2626
@echo " make mcp-telemetry-build - Build and restart the go mcp telemetry server"
2727
@echo " make mcp-pods-build - Build and restart the go mcp pods server"
2828
@echo " make mcp-hub-build - Build and restart the go mcp hub server"
29-
@echo " make all-build - Build and restart all Go services"
29+
@echo " make service-build - Build and restart all go services"
30+
@echo " make mcp-build - Build and restart all MCP servers"
3031
@echo ""
3132
@echo "Host Tier (Systemd & Secrets):"
3233
@echo " make install-services - Install all systemd units"

cmd/web/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
func main() {
11-
if err := web.Build("../../internal/web", "../../dist"); err != nil {
11+
if err := web.Build("./internal/web", "./dist"); err != nil {
1212
log.Fatalf("Site generation failed: %v", err)
1313
}
1414
fmt.Println("Site generated successfully in dist/")

internal/mcp/providers/hub.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,16 @@ func (p *HubProvider) InspectPlatform(ctx context.Context) (map[string]interface
153153
}
154154

155155
services, _ := p.ListHostServices(ctx)
156-
runningCount := 0
156+
healthyCount := 0
157157
for _, s := range services {
158-
if s.Active == "active" {
159-
runningCount++
158+
// Count as healthy if:
159+
// 1. Service is 'active' (running)
160+
// 2. Service is 'inactive' but the substate is 'dead' (successfully completed oneshot)
161+
if s.Active == "active" || (s.Active == "inactive" && s.Sub == "dead") {
162+
healthyCount++
160163
}
161164
}
162-
summary["host_services_running"] = fmt.Sprintf("%d/%d", runningCount, len(p.targetServices))
165+
summary["host_services_healthy"] = fmt.Sprintf("%d/%d", healthyCount, len(p.targetServices))
163166

164167
return summary, nil
165168
}

makefiles/go.mk

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Go Project Configuration
22
GO_PACKAGES = ./cmd/... ./internal/...
33

4-
.PHONY: format test test-cov update vet vuln-scan setup-tailwind web-build proxy-build ingestion-build mcp-telemetry-build mcp-pods-build mcp-hub-build all-build
4+
.PHONY: format test test-cov update vet vuln-scan setup-tailwind web-build proxy-build ingestion-build mcp-telemetry-build mcp-pods-build mcp-hub-build service-build mcp-build
55

66
format:
77
@echo "Formatting Go code..." && \
@@ -29,46 +29,57 @@ vuln-scan:
2929
go run golang.org/x/vuln/cmd/govulncheck@latest $(GO_PACKAGES)
3030

3131
setup-tailwind:
32-
@echo "Downloading tailwind css cli v4..." && \
32+
@echo "Downloading tailwind css cli..." && \
3333
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o tailwindcss && \
3434
chmod +x tailwindcss
3535

3636
web-build: setup-tailwind
37-
@echo "Running web build..." && \
37+
@echo "Generating static site..." && \
3838
rm -rf dist && \
3939
mkdir -p dist && \
40-
(cd cmd/web && go build -o ../../web-ssg .) && \
41-
(cd cmd/web && ../../web-ssg) && \
40+
go run ./cmd/web && \
4241
./tailwindcss -i ./internal/web/templates/input.css -o ./dist/styles.css --minify && \
43-
rm web-ssg && \
4442
rm tailwindcss
4543

4644
proxy-build:
4745
@echo "Updating Proxy..." && \
48-
cd cmd/proxy && go build -o ../../bin/proxy_server . && \
49-
sudo systemctl restart proxy.service
46+
go build -o ./bin/proxy_server ./cmd/proxy && \
47+
sudo install -m 755 ./bin/proxy_server /usr/local/bin/proxy_server && \
48+
sudo systemctl restart proxy.service && \
49+
rm ./bin/proxy_server
5050

5151
ingestion-build:
52-
@echo "Updating ingestion service..." && \
53-
cd cmd/ingestion && go build -o ../../bin/ingestion . && \
54-
sudo systemctl restart ingestion.timer
52+
@echo "Updating Ingestion..." && \
53+
go build -o ./bin/ingestion ./cmd/ingestion && \
54+
sudo install -m 755 ./bin/ingestion /usr/local/bin/ingestion && \
55+
sudo systemctl restart ingestion.service && \
56+
rm ./bin/ingestion
5557

5658
mcp-telemetry-build:
5759
@echo "Updating mcp-telemetry..." && \
58-
cd cmd/mcp-telemetry && go build -o ../../bin/mcp_telemetry .
60+
go build -o ./bin/mcp_telemetry ./cmd/mcp-telemetry && \
61+
sudo install -m 755 ./bin/mcp_telemetry /usr/local/bin/mcp_telemetry && \
62+
rm ./bin/mcp_telemetry
5963

6064
mcp-pods-build:
6165
@echo "Updating mcp-pods..." && \
62-
cd cmd/mcp-pods && go build -o ../../bin/mcp_pods .
66+
go build -o ./bin/mcp_pods ./cmd/mcp-pods && \
67+
sudo install -m 755 ./bin/mcp_pods /usr/local/bin/mcp_pods && \
68+
rm ./bin/mcp_pods
6369

6470
mcp-hub-build:
6571
@echo "Updating mcp-hub..." && \
66-
cd cmd/mcp-hub && go build -o ../../bin/mcp_hub .
72+
go build -o ./bin/mcp_hub ./cmd/mcp-hub && \
73+
sudo install -m 755 ./bin/mcp_hub /usr/local/bin/mcp_hub && \
74+
rm ./bin/mcp_hub
6775

68-
all-build:
76+
service-build:
6977
@echo "Building all services..." && \
7078
make proxy-build && \
71-
make ingestion-build && \
79+
make ingestion-build
80+
81+
mcp-build:
82+
@echo "Building all MCP Servers..." && \
7283
make mcp-telemetry-build && \
7384
make mcp-pods-build && \
74-
make mcp-hub-build
85+
make mcp-hub-build

systemd/ingestion.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Type=oneshot
88
User=server2
99
WorkingDirectory=/home/server2/software/observability-hub
1010
EnvironmentFile=/home/server2/software/observability-hub/.env
11-
ExecStart=/home/server2/software/observability-hub/bin/ingestion
11+
ExecStart=/usr/local/bin/ingestion
1212
StandardOutput=journal
1313
StandardError=journal
1414

systemd/proxy.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Type=simple
77
User=server2
88
WorkingDirectory=/home/server2/software/observability-hub
99
EnvironmentFile=/home/server2/software/observability-hub/.env
10-
ExecStart=/home/server2/software/observability-hub/bin/proxy_server
10+
ExecStart=/usr/local/bin/proxy_server
1111
Restart=always
1212
RestartSec=5
1313
StandardOutput=journal

0 commit comments

Comments
 (0)