diff --git a/.env b/.env deleted file mode 100644 index 35bb0201..00000000 --- a/.env +++ /dev/null @@ -1,28 +0,0 @@ -## Jaeger -COCOS_JAEGER_PORT=6831 -COCOS_JAEGER_FRONTEND=16686 -COCOS_JAEGER_COLLECTOR=14268 -COCOS_JAEGER_CONFIGS=5778 -COCOS_JAEGER_URL=http://jaeger:4318 -COCOS_JAEGER_TRACE_RATIO=1.0 -COCOS_JAEGER_COLLECTOR_OTLP_ENABLED=true -COCOS_JAEGER_OLTP_HTTP_PORT=4318 - -## Core Services - -### Manager -MANAGER_GRPC_HOST="" -MANAGER_GRPC_PORT=7003 -MANAGER_GRPC_SERVER_CERT="" -MANAGER_GRPC_SERVER_KEY="" -AGENT_GRPC_URL="localhost:7002" -AGENT_GRPC_TIMEOUT="" -AGENT_GRPC_CA_CERTS="" -AGENT_GRPC_CLIENT_TLS="" -MANAGER_INSTANCE_ID="" -MANAGER_LOG_LEVEL=debug -MANAGER_QEMU_USE_SUDO=false -MANAGER_QEMU_ENABLE_SEV=false -MANAGER_QEMU_SEV_CBITPOS=51 -MANAGER_QEMU_OVMF_CODE_FILE=/usr/share/OVMF/OVMF_CODE.fd -MANAGER_QEMU_OVMF_VARS_FILE=/usr/share/OVMF/OVMF_VARS.fd diff --git a/Makefile b/Makefile index 7e81c2b8..85b325bc 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,11 @@ VERSION ?= $(shell git describe --abbrev=0 --tags --always) COMMIT ?= $(shell git rev-parse HEAD) TIME ?= $(shell date +%F_%T) EMBED_ENABLED ?= 0 +INSTALL_DIR ?= /usr/local/bin +CONFIG_DIR ?= /etc/cocos +SERVICE_NAME ?= cocos-manager +SERVICE_DIR ?= /etc/systemd/system +SERVICE_FILE = init/systemd/$(SERVICE_NAME).service define compile_service CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \ @@ -18,7 +23,7 @@ define compile_service -o ${BUILD_DIR}/cocos-$(1) cmd/$(1)/main.go endef -.PHONY: all $(SERVICES) $(BACKEND_INFO) +.PHONY: all $(SERVICES) $(BACKEND_INFO) install clean all: $(SERVICES) @@ -34,3 +39,23 @@ protoc: mocks: go generate ./... + +install: $(SERVICES) + install -d $(INSTALL_DIR) + install $(BUILD_DIR)/cocos-cli $(INSTALL_DIR)/cocos-cli + install $(BUILD_DIR)/cocos-manager $(INSTALL_DIR)/cocos-manager + install -d $(CONFIG_DIR) + install cocos-manager.env $(CONFIG_DIR)/cocos-manager.env + +clean: + rm -rf $(BUILD_DIR) + +run: install_service + sudo systemctl start $(SERVICE_NAME).service + +stop: + sudo systemctl stop $(SERVICE_NAME).service + +install_service: + sudo install -m 644 $(SERVICE_FILE) $(SERVICE_DIR)/$(SERVICE_NAME).service + sudo systemctl daemon-reload diff --git a/cocos-manager.env b/cocos-manager.env new file mode 100644 index 00000000..adbac897 --- /dev/null +++ b/cocos-manager.env @@ -0,0 +1,58 @@ +# Environment Configuration for Cocos + +# Jaeger Tracing +COCOS_JAEGER_URL=http://localhost:4318 +COCOS_JAEGER_TRACE_RATIO=1.0 + +# Manager Service Configuration +MANAGER_INSTANCE_ID= +MANAGER_BACKEND_MEASUREMENT_BINARY=../../build +MANAGER_GRPC_CLIENT_CERT= +MANAGER_GRPC_CLIENT_KEY= +MANAGER_GRPC_SERVER_CA_CERTS= +MANAGER_GRPC_URL=localhost:7001 +MANAGER_GRPC_TIMEOUT=60s + +# QEMU Configuration +MANAGER_QEMU_MEMORY_SIZE=25G +MANAGER_QEMU_MEMORY_SLOTS=5 +MANAGER_QEMU_MAX_MEMORY=30G +MANAGER_QEMU_OVMF_CODE_IF=pflash +MANAGER_QEMU_OVMF_CODE_FORMAT=raw +MANAGER_QEMU_OVMF_CODE_UNIT=0 +MANAGER_QEMU_OVMF_CODE_FILE=/usr/share/OVMF/x64/OVMF_CODE.fd +MANAGER_QEMU_OVMF_CODE_READONLY=on +MANAGER_QEMU_OVMF_VARS_IF=pflash +MANAGER_QEMU_OVMF_VARS_FORMAT=raw +MANAGER_QEMU_OVMF_VARS_UNIT=1 +MANAGER_QEMU_OVMF_VARS_FILE=/usr/share/OVMF/x64/OVMF_VARS.fd +MANAGER_QEMU_NETDEV_ID=vmnic +MANAGER_QEMU_HOST_FWD_AGENT=7020 +MANAGER_QEMU_GUEST_FWD_AGENT=7002 +MANAGER_QEMU_VIRTIO_NET_PCI_DISABLE_LEGACY=on +MANAGER_QEMU_VIRTIO_NET_PCI_IOMMU_PLATFORM=true +MANAGER_QEMU_VIRTIO_NET_PCI_ADDR=0x2 +MANAGER_QEMU_VIRTIO_NET_PCI_ROMFILE= +MANAGER_QEMU_DISK_IMG_KERNEL_FILE=/home/sammyk/Documents/cocos-ai/cmd/manager/img/bzImage +MANAGER_QEMU_DISK_IMG_ROOTFS_FILE=/home/sammyk/Documents/cocos-ai/cmd/manager/img/rootfs.cpio.gz +MANAGER_QEMU_SEV_ID=sev0 +MANAGER_QEMU_SEV_CBITPOS=51 +MANAGER_QEMU_SEV_REDUCED_PHYS_BITS=1 +MANAGER_QEMU_HOST_DATA= +MANAGER_QEMU_VSOCK_ID=vhost-vsock-pci0 +MANAGER_QEMU_VSOCK_GUEST_CID=3 +MANAGER_QEMU_VSOCK_VNC=0 +MANAGER_QEMU_BIN_PATH=qemu-system-x86_64 +MANAGER_QEMU_USE_SUDO=true +MANAGER_QEMU_ENABLE_SEV=false +MANAGER_QEMU_ENABLE_SEV_SNP=false +MANAGER_QEMU_ENABLE_KVM=true +MANAGER_QEMU_MACHINE=q35 +MANAGER_QEMU_CPU=EPYC +MANAGER_QEMU_SMP_COUNT=4 +MANAGER_QEMU_SMP_MAXCPUS=16 +MANAGER_QEMU_MEM_ID=ram1 +MANAGER_QEMU_KERNEL_HASH=false +MANAGER_QEMU_NO_GRAPHIC=true +MANAGER_QEMU_MONITOR=pty +MANAGER_QEMU_HOST_FWD_RANGE=6100-6200 diff --git a/init/systemd/cocos-manager.service b/init/systemd/cocos-manager.service new file mode 100644 index 00000000..913a7349 --- /dev/null +++ b/init/systemd/cocos-manager.service @@ -0,0 +1,12 @@ +[Unit] +Description=Cocos Manager +After=network.target + +[Service] +ExecStart=cocos-manager +Restart=on-failure +RestartSec=5s +EnvironmentFile=/etc/cocos/cocos-manager.env + +[Install] +WantedBy=multi-user.target