diff --git a/Dockerfile b/Dockerfile index 3d5aec7..f3ab438 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ RUN set -eux; \ apt remove docker.io -y ; \ rm -rf /var/lib/apt/lists/* -COPY --from=builder /work/build/system-agent /usr/local/bin/system-agent +COPY --from=builder /work/build/aospace /usr/local/bin/aospace COPY --from=builder /work/supervisord.conf /etc/supervisor/supervisord.conf EXPOSE 5678 diff --git a/Makefile b/Makefile index 97c6787..388d10c 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -NAME=system-agent +NAME=aospace EXE=$(NAME)$(shell go env GOEXE) DATE=$(shell date '+%F-%T') -VERSION=$(NAME)-AO.space-$(DATE) -VERSIONNUMBER=1.0.0 +BRANCH=$(shell git symbolic-ref HEAD | cut -d"/" -f 3) +COMMIT=$(shell git rev-parse HEAD | cut -c1-7) +VERSIONNUMBER="1.0.1" +VERSION=$(NAME)--"Agent-"$(VERSIONNUMBER)--$(DATE)-$(BRANCH)-$(COMMIT) LDFLAGS=-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.VersionNumber=${VERSIONNUMBER}'" SOURCES=$(shell ls **/*.go) + .PHONY: all all: exe @@ -27,6 +30,7 @@ all: exe exe: $(SOURCES) Makefile echo "building..." go env -w GO111MODULE=on + go env -w GOPROXY="https://goproxy.io,direct" go build $(OPTIONS) $(LDFLAGS) -o build/$(NAME) .PHONY: clean diff --git a/Makefile.amd64 b/Makefile.amd64 index a536c50..e15f18b 100644 --- a/Makefile.amd64 +++ b/Makefile.amd64 @@ -12,18 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -NAME=system-agent +NAME=aospace EXE=$(NAME)$(shell go env GOEXE) DATE=$(shell date '+%F-%T') BRANCH=$(shell git symbolic-ref HEAD | cut -d"/" -f 3) COMMIT=$(shell git rev-parse HEAD | cut -c1-7) ARCH ?= amd64 -#OPTIONS=-trimpath -mod=vendor -VERSIONNUMBER="VERSIONNUMBER_PLACEHOLDER" -VERSION=$(NAME)--"EulixSpace-RaspberryPi-"$(VERSIONNUMBER)--$(DATE)-$(BRANCH)-$(COMMIT) +VERSIONNUMBER="1.0.1" +VERSION=$(NAME)--"Agent-"$(VERSIONNUMBER)--$(DATE)-$(BRANCH)-$(COMMIT) LDFLAGS=-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.VersionNumber=${VERSIONNUMBER}'" SOURCES=$(shell ls **/*.go) -# CHECKS:=check .PHONY: all all: exe @@ -31,7 +29,6 @@ all: exe .PHONY: exe exe: $(SOURCES) Makefile echo "building..." - #swag init -g biz/web/http_server.go go env -w GO111MODULE=on go env -w GOPROXY="https://goproxy.io,direct" GOOS=linux GOARCH=${ARCH} go build $(OPTIONS) $(LDFLAGS) -o build/$(NAME) diff --git a/Makefile.riscv64 b/Makefile.riscv64 new file mode 100644 index 0000000..63ad2a5 --- /dev/null +++ b/Makefile.riscv64 @@ -0,0 +1,42 @@ +# Copyright (c) 2022 Institute of Software, Chinese Academy of Sciences (ISCAS) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +NAME=aospace +EXE=$(NAME)$(shell go env GOEXE) +DATE=$(shell date '+%F-%T') +BRANCH=$(shell git symbolic-ref HEAD | cut -d"/" -f 3) +COMMIT=$(shell git rev-parse HEAD | cut -c1-7) +ARCH ?= riscv64 +VERSIONNUMBER="1.0.1" +VERSION=$(NAME)--"Agent-"$(VERSIONNUMBER)--$(DATE)-$(BRANCH)-$(COMMIT) +LDFLAGS=-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.VersionNumber=${VERSIONNUMBER}'" +SOURCES=$(shell ls **/*.go) + +.PHONY: all +all: exe + +.PHONY: exe +exe: $(SOURCES) Makefile + echo "building..." + #swag init -g biz/web/http_server.go + go env -w GO111MODULE=on + go env -w GOPROXY="https://goproxy.io,direct" + # GOOS=linux GOARCH=${ARCH} go build $(OPTIONS) $(LDFLAGS) -o build/$(NAME) + go build $(OPTIONS) $(LDFLAGS) -o build/$(NAME) + +.PHONY: clean +clean: + go clean -i + rm -rf build/* + diff --git a/res/aospace.service b/res/aospace.service new file mode 100644 index 0000000..cbf818f --- /dev/null +++ b/res/aospace.service @@ -0,0 +1,10 @@ +[Unit] +Description=AO.space Agent +After=bluetooth.target network.target time-sync.target + +[Service] +ExecStart=/usr/local/bin/aospace +Restart=always + +[Install] +WantedBy=default.target diff --git a/supervisord.conf b/supervisord.conf index f7da52d..c4db6a3 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -16,7 +16,7 @@ serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [program:system-agent] -command=/usr/local/bin/system-agent +command=/usr/local/bin/aospace autostart=true autorestart=true startretries=0