~ritho/rweb

70d30802c84d227d09ac297982b32285ec975adb — Ritho a month ago 38c9a7d main
New debian release.

Signed-off-by: Ritho <palvarez@ritho.net>
5 files changed, 63 insertions(+), 23 deletions(-)

M Makefile
M conf/Makefile
M debian/changelog
M debian/rules
M scripts/web.service
M Makefile => Makefile +17 -17
@@ 16,15 16,15 @@
#  along with web. If not, see <http://www.gnu.org/licenses/>.

# Load the configuration variables.
include Config.mk
TOPDIR?=$(realpath .)
include $(TOPDIR)/Config.mk

# This version-strategy uses git tags to set the version string
VERSION := $(shell date +%Y%m%d%H%M%S)
PWD ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PKG := git.sr.ht/~ritho/$(BIN)
.DEFAULT_GOAL := build

export REPORTS_DIR=$(PWD)/reports
export REPORTS_DIR=$(TOPDIR)/reports

version:
	@echo $(VERSION)


@@ 37,17 37,17 @@ test-update:
	@go test ./... -tags=update

lint:
	@golangci-lint run -c $(PWD)/.golangci.yaml
	@golangci-lint run -c $(TOPDIR)/.golangci.yaml

update-lint:
	@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin latest

build-dirs:
	@mkdir -p $(PWD)/build
	@mkdir -p $(PWD)/bin/$(ARCH)
	@mkdir -p $(TOPDIR)/build
	@mkdir -p $(TOPDIR)/bin/$(ARCH)

clean:
	@rm -fr $(PWD)/bin
	@rm -fr $(TOPDIR)/bin
	@rm -fr cpu-*.log mem-*.log block-*.log *.test
	@rm -fr .web.pid
	@rm -fr reports tmp cover.out


@@ 58,13 58,13 @@ clean:
build:
	@$(MAKE) build-dirs
	@$(MAKE) -C $(CONF_DIR) install
	@go build -o $(PWD)/bin/${BIN} $(PWD)/cmd/${BIN}/main.go
	@go build -o $(TOPDIR)/bin/${BIN} $(TOPDIR)/cmd/${BIN}/main.go

.PHONY: install
install:
install: build
	@ASSETS_DIR=/etc/${BIN}/assets PORT=80 ${MAKE} -C $(CONF_DIR) install
	@install -m 0755 -d $(DESTDIR)/usr/bin
	@install $(BUILDDIR)/bin/web $(DESTDIR)/usr/bin
	@install $(TOPDIR)/bin/web $(DESTDIR)/usr/bin
	@install -m 0755 -d $(DESTDIR)/etc/init.d
	@install $(TOPDIR)/scripts/web $(DESTDIR)/etc/init.d/web
	@install -m 0755 -d $(ASSETS_DIR)


@@ 90,16 90,16 @@ deb:

start:
	@$(MAKE) build
	@if [ ! -f $(PWD)/.$(BIN).pid ]; then \
	@if [ ! -f $(TOPDIR)/.$(BIN).pid ]; then \
		echo -n "Starting $(BIN)"; \
		$(PWD)/bin/$(BIN) -logtostderr=true -config $(PWD)/conf/web.yaml 1> $(BIN).log < /dev/null 2>&1 & \
		$(TOPDIR)/bin/$(BIN) -logtostderr=true -config $(TOPDIR)/conf/web.yaml 1> $(BIN).log < /dev/null 2>&1 & \
		export PID=$$! ; \
		echo $$PID > $(PWD)/.$(BIN).pid ; \
		echo $$PID > $(TOPDIR)/.$(BIN).pid ; \
		while  ! curl $(HOST):$(PORT)/healthcheck > /dev/null 2>&1; do \
			if ! ps -p $$PID > /dev/null ; then \
				echo; \
				echo -n "Error running the server"; \
				rm -f $(PWD)/.$(BIN).pid; \
				rm -f $(TOPDIR)/.$(BIN).pid; \
				break; \
			fi; \
			/bin/sleep 2; \


@@ 109,14 109,14 @@ start:
	fi

stop:
	@if [ -f $(PWD)/.$(BIN).pid ]; then \
	@if [ -f $(TOPDIR)/.$(BIN).pid ]; then \
		echo -n "Stopping $(BIN)"; \
		kill -s HUP `cat $(PWD)/.$(BIN).pid`; \
		kill -s HUP `cat $(TOPDIR)/.$(BIN).pid`; \
		while curl $(HOST):$(PORT)/healthcheck > /dev/null 2>&1; do \
			/bin/sleep 2; \
			echo -n "."; \
		done; \
		rm -f $(PWD)/.$(BIN).pid; \
		rm -f $(TOPDIR)/.$(BIN).pid; \
		echo; \
	fi


M conf/Makefile => conf/Makefile +19 -3
@@ 1,8 1,24 @@
# Copyright (C) 2021-2024 Pablo Alvarez de Sotomayor Posadillo
#
#  This file is part of web.
#
#  web is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  web is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with web. If not, see <http://www.gnu.org/licenses/>.

TOPDIR?=$(realpath ..)
PWD = $(shell dirname $(realpath .))
include $(TOPDIR)/Config.mk

DIRS = 
DIRS =
SRCS = web.yaml

install:


@@ 12,7 28,7 @@ install:
	@for i in $(SRCS); do \
		echo "Installing $(PWD)/conf/$$i.in in $(CONF_DIR)/$$i" ; \
		if [ -f $(PWD)/conf/$$i.in ]; then \
			install $(PWD)/conf/$$i.in $(CONF_DIR)/$$i ; \
			install $(TOPDIR)/conf/$$i.in $(CONF_DIR)/$$i ; \
			perl -i -pne 's/%(\w+?)%/$$ENV{$$1}/ge' $(CONF_DIR)/$$i ; \
		fi ; \
	done

M debian/changelog => debian/changelog +6 -0
@@ 1,3 1,9 @@
web (1.0.6) unstable; urgency=low

  * Update the go version to 1.21.

 -- Pablo Alvarez de Sotomayor Posadillo <palvarez@ritho.net>  Mon, 01 Jan 2024 23:38:00 +0200

web (1.0.5) unstable; urgency=low

  * Set the right order for the blog categories.

M debian/rules => debian/rules +20 -2
@@ 1,5 1,23 @@
#!/usr/bin/make -f

# Copyright (C) 2021-2024 Pablo Alvarez de Sotomayor Posadillo
#
#  This file is part of web.
#
#  web is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  web is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with web. If not, see <http://www.gnu.org/licenses/>.


export DH_VERBOSE=1
export DH_GOPKG=git.sr.ht/~ritho/rweb
export DH_OPTIONS


@@ 13,7 31,7 @@ export ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
	dh $@ --buildsystem=golang --with=golang

override_dh_auto_install:
	DESTDIR=$$(pwd)/debian/web ASSETS_DIR=$$(pwd)/debian/web/etc/web/assets LOG_DIR=$$(pwd)/debian/web/var/log RUN_DIR=$$(pwd)/debian/web/var/run TMP_DIR=$$(pwd)/debian/web/tmp $(MAKE) install
	GOCACHE=$$(pwd) TOPDIR=$$(pwd) CONF_DIR=$$(pwd)/conf DESTDIR=$$(pwd)/debian/web ASSETS_DIR=$$(pwd)/debian/web/etc/web/assets LOG_DIR=$$(pwd)/debian/web/var/log RUN_DIR=$$(pwd)/debian/web/var/run TMP_DIR=$$(pwd)/debian/web/tmp $(MAKE) install
	install -m 0755 -d $$(pwd)/debian/web/etc/init.d
	install $$(pwd)/scripts/web $$(pwd)/debian/web/etc/init.d/web
	install -m 0755 -d $$(pwd)/debian/web/lib/systemd/system/


@@ 22,4 40,4 @@ override_dh_auto_install:
	install $$(pwd)/scripts/rsyslog.conf $$(pwd)/debian/web/etc/rsyslog.d/web.conf

override_dh_golang:
	go mod tidy
	GOCACHE=$$(pwd) go mod tidy

M scripts/web.service => scripts/web.service +1 -1
@@ 6,7 6,7 @@ After=network.target nss-lookup.target
[Service]
Type=simple
PIDFile=/var/run/web.pid
ExecStart=/usr/bin/web -logtostderr=true
ExecStart=/usr/bin/web
ExecReload=-/sbin/start-stop-daemon --quiet -T -s USR1 --pidfile /var/run/web.pid
ExecStop=-/sbin/start-stop-daemon --quiet -T -s INT --pidfile /var/run/web.pid
TimeoutStopSec=5