-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
170 lines (140 loc) · 5.45 KB
/
Makefile
File metadata and controls
170 lines (140 loc) · 5.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# LiteMIDgo Makefile
.PHONY: help build server agent clean test restart stop status docker-build docker-up docker-down docker-logs docker-clean
# Default target
help: ## Show this help message
@echo "LiteMIDgo - Lightweight ServiceNow MID Server Alternative"
@echo ""
@echo "Available commands:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# Build targets
build: ## Build both server and agent
@echo "🔨 Building LiteMIDgo server..."
go build -o litemidgo .
@echo "🔨 Building LiteMIDgo agent..."
cd agent && go build -o litemidgo-agent .
@echo "✅ Build complete!"
build-server: ## Build only the server
@echo "🔨 Building LiteMIDgo server..."
go build -o litemidgo .
@echo "✅ Server build complete!"
build-agent: ## Build only the agent
@echo "🔨 Building LiteMIDgo agent..."
cd agent && go build -o litemidgo-agent .
@echo "✅ Agent build complete!"
# Run targets
server: ## Run the server (builds first if needed)
@if [ ! -f ./litemidgo ]; then $(MAKE) build-server; fi
@echo "🚀 Starting LiteMIDgo server..."
./litemidgo server-simple
agent: ## Run the agent (builds first if needed)
@if [ ! -f ./agent/litemidgo-agent ]; then $(MAKE) build-agent; fi
@echo "🚀 Starting LiteMIDgo agent..."
cd agent && ./litemidgo-agent daemon --interval 10
debug-server: ## Run server with debug mode
@if [ ! -f ./litemidgo ]; then $(MAKE) build-server; fi
@echo "🐛 Starting LiteMIDgo server in debug mode..."
./litemidgo server-simple --debug
debug-agent: ## Run agent with debug mode
@if [ ! -f ./agent/litemidgo-agent ]; then $(MAKE) build-agent; fi
@echo "🐛 Starting LiteMIDgo agent in debug mode..."
cd agent && ./litemidgo-agent daemon --debug --interval 10
# Management targets
start: ## Start both server and agent in background
@echo "🚀 Starting LiteMIDgo services..."
$(MAKE) stop > /dev/null 2>&1 || true
@if [ ! -f ./litemidgo ]; then $(MAKE) build-server > /dev/null; fi
@if [ ! -f ./agent/litemidgo-agent ]; then $(MAKE) build-agent > /dev/null; fi
./litemidgo server-simple > server.log 2>&1 &
@echo "✅ Server started (PID: $$!)"
cd agent && ./litemidgo-agent daemon --interval 10 > agent.log 2>&1 &
@echo "✅ Agent started (PID: $$!)"
@echo "📋 Use 'make status' to check running services"
stop: ## Stop all running services
@echo "🛑 Stopping LiteMIDgo services..."
@pkill -f "litemidgo server" 2>/dev/null || echo "No server running"
@pkill -f "litemidgo-agent daemon" 2>/dev/null || echo "No agent running"
@echo "✅ Services stopped"
restart: ## Restart both services
@echo "🔄 Restarting LiteMIDgo services..."
$(MAKE) stop
sleep 2
$(MAKE) start
status: ## Show status of running services
@echo "📊 LiteMIDgo Service Status:"
@echo ""
@ps aux | grep -E "(liteMIDgo|litemidgo)" | grep -v grep || echo "No services running"
# Utility targets
logs: ## Show logs from background services
@echo "📋 Server Logs:"
@if [ -f server.log ]; then tail -20 server.log; else echo "No server log file"; fi
@echo ""
@echo "📋 Agent Logs:"
@if [ -f agent/agent.log ]; then tail -20 agent/agent.log; else echo "No agent log file"; fi
test: ## Run tests
@echo "🧪 Running tests..."
go test ./...
test-config: ## Test configuration and ServiceNow connection
@echo "🔧 Testing configuration..."
./litemidgo config test
config: ## Run interactive configuration setup
@echo "⚙️ Starting configuration setup..."
./litemidgo config
collect: ## Collect and display system metrics (agent)
@echo "📊 Collecting system metrics..."
cd agent && ./litemidgo-agent collect
# Docker targets
docker-build: ## Build Docker images
@echo "🐳 Building Docker images..."
docker-compose build
docker-up: ## Start services with Docker Compose
@echo "🐳 Starting LiteMIDgo services with Docker..."
@if [ ! -f .env ]; then \
echo "📋 Creating .env file from template..."; \
cp .env.docker .env; \
echo "⚠️ Please update .env with your actual ServiceNow credentials"; \
fi
docker-compose up -d
docker-down: ## Stop Docker services
@echo "🐳 Stopping Docker services..."
docker-compose down
docker-logs: ## Show Docker service logs
@echo "📋 Docker service logs:"
docker-compose logs -f
docker-status: ## Show Docker service status
@echo "📊 Docker Service Status:"
docker-compose ps
docker-clean: ## Clean Docker images and containers
@echo "🧹 Cleaning up Docker..."
docker-compose down --rmi all --volumes --remove-orphans
docker system prune -f
docker-restart: ## Restart Docker services
@echo "🔄 Restarting Docker services..."
$(MAKE) docker-down
sleep 2
$(MAKE) docker-up
# Development targets
dev: ## Start services in development mode with auto-restart
@echo "🔧 Starting development mode..."
@echo "Server and agent will restart automatically on file changes"
@echo "Press Ctrl+C to stop"
@while true; do $(MAKE) restart; sleep 30; done
clean: ## Clean build artifacts and logs
@echo "🧹 Cleaning up..."
rm -f litemidgo agent/litemidgo-agent
rm -f server.log agent.log
rm -f *.log
@echo "✅ Clean complete!"
install-deps: ## Install Go dependencies
@echo "📦 Installing dependencies..."
go mod download
cd agent && go mod download
@echo "✅ Dependencies installed!"
# Quick start targets
quick-start: ## Build and start both services
@echo "🚀 Quick starting LiteMIDgo..."
$(MAKE) build
$(MAKE) start
quick-stop: ## Stop services and clean up
@echo "🛑 Quick stopping LiteMIDgo..."
$(MAKE) stop
$(MAKE) clean