Add setup and deploy support.

Fix readme.
This commit is contained in:
Captain ALM 2023-12-01 23:33:31 +00:00
parent 59b5d686d4
commit 2e11c55981
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
5 changed files with 65 additions and 18 deletions

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SwUserDefinedSpecifications">
<option name="specTypeByUrl">
<map />
</option>
</component>
</project>

View File

@ -1,18 +1,21 @@
SHELL := /bin/bash SHELL := /bin/bash
BIN := dist/gopkghsrv PRODUCT_NAME := gopkghsrv
ENTRY_POINT := ./cmd/gopkghsrv BIN := dist/${PRODUCT_NAME}
DNAME := ${PRODUCT_NAME}_
ENTRY_POINT := ./cmd/${PRODUCT_NAME}
HASH := $(shell git rev-parse --short HEAD) HASH := $(shell git rev-parse --short HEAD)
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH}) COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S') BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
VERSION := ${HASH} VERSION := ${HASH}
LD_FLAGS := -s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}' LD_FLAGS := -s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}' -X 'main.buildName=${PRODUCT_NAME}'
COMP_BIN := go COMP_BIN := go
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
BIN := $(BIN).exe BIN := $(BIN).exe
DNAME := $(DNAME).exe
endif endif
.PHONY: build dev test clean .PHONY: build dev test clean deploy d setup s
build: build:
mkdir -p dist/ mkdir -p dist/
@ -24,8 +27,30 @@ dev:
./${BIN} ./${BIN}
test: test:
go test ${COMP_BIN} test
clean: clean:
go clean ${COMP_BIN} clean
rm -r -f dist/ rm -r -f dist/
setup:
sudo cp "${PRODUCT_NAME}.service" /etc/systemd/system
sudo mkdir -p "/etc/${PRODUCT_NAME}"
sudo touch "/etc/${PRODUCT_NAME}/.env"
sudo systemctl daemon-reload
s:
sudo cp "${DNAME}.service" /etc/systemd/system
sudo mkdir -p "/etc/${DNAME}"
sudo touch "/etc/${DNAME}/.env"
sudo systemctl daemon-reload
deploy: build
sudo systemctl stop "${PRODUCT_NAME}"
sudo cp "${BIN}" /usr/local/bin
sudo systemctl start "${PRODUCT_NAME}"
d: build
sudo systemctl stop "${DNAME}"
sudo cp "${BIN}" "/usr/local/bin/${DNAME}"
sudo systemctl start "${DNAME}"

View File

@ -1,6 +1,6 @@
# GO Package Header Server # GO Package Header Server
[![Build Status](https://ci.mrmelon54.xyz/api/badges/alfred/GOPackageHeaderServer/status.svg)](https://ci.mrmelon54.xyz/alfred/GOPackageHeaderServer) [![Build Status](https://ci.mrmelon54.com/api/badges/alfred/GOPackageHeaderServer/status.svg)](https://ci.mrmelon54.com/alfred/GOPackageHeaderServer)
This allows for the required meta headers to be outputted in order for the GO package system to find the source files of the package. This allows for the required meta headers to be outputted in order for the GO package system to find the source files of the package.
@ -8,11 +8,11 @@ The outputter can be configured in runtime, the server has a YAML configuration.
The outputter can be used to add the extra meta tags to the head of the HTML document. The outputter can be used to add the extra meta tags to the head of the HTML document.
Maintainer: Maintainer:
[Captain ALM](https://code.mrmelon54.xyz/alfred) [Captain ALM](https://code.mrmelon54.com/alfred)
License: License:
[BSD 3-Clause](https://code.mrmelon54.xyz/alfred/GOPackageHeaderServer/src/branch/master/LICENSE.md) [BSD 3-Clause](https://code.mrmelon54.com/alfred/GOPackageHeaderServer/src/branch/master/LICENSE.md)
Example configuration: Example configuration:
[config.example.yml](https://code.mrmelon54.xyz/alfred/GOPackageHeaderServer/src/branch/master/config.example.yml) [config.example.yml](https://code.mrmelon54.com/alfred/GOPackageHeaderServer/src/branch/master/config.example.yml)
The configuration must by placed in a .data sub-directory from the executable. A .env file must also be generated (Can be empty). The configuration must by placed in a .data sub-directory from the executable. A .env file must also be generated (Can be empty).

15
gopkghsrv.service Normal file
View File

@ -0,0 +1,15 @@
# GO PKG Header Service
[Unit]
Description=GO PKG Header Service
[Service]
WorkingDirectory=/etc/gopkghsrv
ExecStart=/usr/local/bin/gopkghsrv
User=www-data
Group=www-data
Type=simple
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target

15
gopkghsrv_.service Normal file
View File

@ -0,0 +1,15 @@
# GO PKG Header Service (Dev)
[Unit]
Description=GO PKG Header Service (Dev)
[Service]
WorkingDirectory=/etc/gopkghsrv_
ExecStart=/usr/local/bin/gopkghsrv_
User=www-data
Group=www-data
Type=simple
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target