Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Jun 24, 2024
1 parent ed2e1d0 commit 5c93f88
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions common/updown-badge-server.knf
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
# Path to log file
file: {log:dir}/updown-badge-server.log

# Log permissions
perms: 600
# Log file mode
mode: 0600

# Default log level (debug/info/warn/error/crit)
level: info
13 changes: 8 additions & 5 deletions common/updown-badge-server.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
User=updownbs
ExecStart=/usr/bin/updown-badge-server
ExecReload=kill -HUP $MAINPID
StandardError=syslog
SyslogIdentifier=updown-badge-server
Type=simple
User=updown
EnvironmentFile=/etc/sysconfig/updown-badge-server
ExecStart=/usr/bin/updown-badge-server -c /etc/updown-badge-server.knf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
StandardError=file:/var/log/updown-badge-server/startup.log
PrivateTmp=true

[Install]
WantedBy=multi-user.target
14 changes: 10 additions & 4 deletions common/updown-badge-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Summary: Service for generating badges for updown.io checks
Name: updown-badge-server
Version: 1.3.1
Version: 1.3.2
Release: 0%{?dist}
Group: Applications/System
License: Apache License, Version 2.0
Expand Down Expand Up @@ -43,13 +43,15 @@ Service for generating badges for updown.io checks.
%{crc_check}

%setup -q

%build
if [[ ! -d "%{name}/vendor" ]] ; then
echo "This package requires vendored dependencies"
echo -e "----\nThis package requires vendored dependencies\n----"
exit 1
elif [[ -f "%{name}/%{name}" ]] ; then
echo -e "----\nSources must not contain precompiled binaries\n----"
exit 1
fi

%build
pushd %{name}
go build %{name}.go
cp LICENSE ..
Expand Down Expand Up @@ -98,6 +100,10 @@ exit 0
################################################################################

%changelog
* Mon Jun 24 2024 Anton Novojilov <[email protected]> - 1.3.2-0
- Code refactoring
- Dependencies update

* Sat Mar 30 2024 Anton Novojilov <[email protected]> - 1.3.1-0
- Improved support information gathering
- Code refactoring
Expand Down
15 changes: 7 additions & 8 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/essentialkaos/ek/v12/signal"
"github.com/essentialkaos/ek/v12/support"
"github.com/essentialkaos/ek/v12/support/deps"
"github.com/essentialkaos/ek/v12/terminal"
"github.com/essentialkaos/ek/v12/terminal/tty"
"github.com/essentialkaos/ek/v12/usage"

Expand All @@ -41,7 +42,7 @@ import (
// Basic service info
const (
APP = "UpDownBadgeServer"
VER = "1.3.1"
VER = "1.3.2"
DESC = "Service for generating badges for updown.io checks"
)

Expand Down Expand Up @@ -78,7 +79,7 @@ const (
SERVER_REDIRECT = "server:redirect"
LOG_DIR = "log:dir"
LOG_FILE = "log:file"
LOG_PERMS = "log:perms"
LOG_MODE = "log:mode"
LOG_LEVEL = "log:level"
)

Expand Down Expand Up @@ -109,11 +110,9 @@ func Run(gomod []byte) {

_, errs := options.Parse(optMap)

if len(errs) != 0 {
for _, err := range errs {
log.Crit(err.Error())
}

if !errs.IsEmpty() {
terminal.Error("Options parsing errors:")
terminal.Error(errs.String())
os.Exit(1)
}

Expand Down Expand Up @@ -236,7 +235,7 @@ func registerSignalHandlers() {

// setupLogger configures logger subsystems
func setupLogger() {
err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 0644))
err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_MODE, 0644))

if err != nil {
log.Crit(err.Error())
Expand Down

0 comments on commit 5c93f88

Please sign in to comment.