Conversion to Makefile and systemd unit

This commit is contained in:
Steve Howes
2023-10-18 15:14:54 +01:00
parent 1d2c324747
commit 8dc785d843
6 changed files with 60 additions and 20 deletions
-1
View File
@@ -1 +0,0 @@
node_modules
-2
View File
@@ -1,2 +0,0 @@
node_modules
.idea/
-14
View File
@@ -1,14 +0,0 @@
FROM paulcager/go-base:latest as build
COPY * ./
RUN CGO_ENABLED=0 go install -v ./... && \
sha256sum /go/bin/osgrid-server
FROM scratch
WORKDIR /app
COPY --from=build /go/bin/osgrid-server .
EXPOSE 9090
CMD [ "/app/osgrid-server" ]
+31
View File
@@ -0,0 +1,31 @@
.DEFAULT_GOAL := build
clean:
rm -f osgrid-server
fmt:
go fmt ./...
.PHONY:fmt
lint: fmt
golint ./...
.PHONY:lint
vet: fmt
go vet ./...
.PHONY:vet
build: vet
go build
.PHONY:build
run: build
./osgrid-server
.PHONY:run
install: build
mkdir -p /opt/sartools/
useradd sartools || true
chown sartools:sartools /opt/sartools/
cp osgrid-server /opt/sartools/
cp osgrid-server.service /etc/systemd/system/
+12 -3
View File
@@ -1,13 +1,22 @@
# osgrid-server - _Ordnance Survey Grid Ref Converter_ # osgrid-server - _Ordnance Survey Grid Ref Converter_
This project implements a simple REST server to allow conversion between Ordnance Survey This project implements a simple REST server to allow conversion between Ordnance Survey
grid references and latitude / longitude. grid references and latitude / longitude. This fork runs without docker and includes
a makefile implementing install, run, build, vet, lint, fmt and clean. As this is part
of an intended set of SAR tools, installation is to /opt/sartools/ and will create the
user 'sartools' if it does not exist.
## Pre-requisites
- go
- make
- golint (optional)
## Usage ## Usage
The easiest way is to start the server using Docker: To use this stand-alone (non Docker variant) on http://localhost:9090 just run:
docker run -d --rm --name osgrid-server -p 9090:9090 paulcager/osgrid-server make install
service osgrid-server
A grid reference may then be converted to a lat / lon: A grid reference may then be converted to a lat / lon:
+17
View File
@@ -0,0 +1,17 @@
[Unit]
Description=OS Grid Server
ConditionPathExists=/opt/sartools/osgrid-server
After=network.target
[Service]
Type=simple
User=sartools
Group=sartools
WorkingDirectory=/opt/sartools/
ExecStart=/opt/sartools/osgrid-server --port localhost:9090
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=osgrid-server
[Install]
WantedBy=multi-user.target