Skip to content

Commit

Permalink
Add a systemd standard opentsdb service script to launch using the port
Browse files Browse the repository at this point in the history
defined in the config file. Fixes #2033
  • Loading branch information
manolama committed Jul 27, 2021
1 parent b89fded commit fc34c0e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2011-2012 The OpenTSDB Authors.
# Copyright (C) 2011-2021 The OpenTSDB Authors.
#
# This library is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
Expand Down Expand Up @@ -30,6 +30,7 @@ dist_noinst_SCRIPTS = src/create_table.sh src/upgrade_1to2.sh src/mygnuplot.sh \
src/mygnuplot.bat src/opentsdb.conf tools/opentsdb_restart.py src/logback.xml
dist_noinst_DATA = pom.xml.in build-aux/rpm/opentsdb.conf \
build-aux/rpm/logback.xml build-aux/rpm/init.d/opentsdb \
build-aux/rpm/systemd/opentsdb.service \
build-aux/rpm/systemd/[email protected]
tsdb_SRC := \
src/core/AbstractSpanGroup.java \
Expand Down Expand Up @@ -734,6 +735,7 @@ install-data-etc:
init_file="$(top_srcdir)/build-aux/rpm/init.d/opentsdb" ; \
echo " $(INSTALL_SCRIPT)" $$init_file "$$destdatainitdir" ; \
$(INSTALL_SCRIPT) $$init_file "$$destdatainitdir" || exit 1; \
systemd_file="$(top_srcdir)/build-aux/rpm/systemd/opentsdb.service" ; \
systemd_file="$(top_srcdir)/build-aux/rpm/systemd/[email protected]" ; \
echo " $(INSTALL_SCRIPT)" $$systemd_file "$$destdatasystemddir" ; \
$(INSTALL_SCRIPT) $$systemd_file "$$destdatasystemddir" || exit 1;
Expand Down
2 changes: 1 addition & 1 deletion build-aux/rpm/opentsdb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tsd.http.staticroot = /usr/share/opentsdb/static/

# Where TSD should write it's cache files to
# *** REQUIRED ***
tsd.http.cachedir = /tmp/opentsdb
tsd.http.cachedir = /var/tmp/opentsdb

# --------- CORE ----------
# Whether or not to automatically create UIDs for new metric types, default
Expand Down
14 changes: 14 additions & 0 deletions build-aux/rpm/systemd/opentsdb.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=OpenTSDB
After=network-online.target
Before=shutdown.target

[Service]
Type=simple
User=opentsdb
Group=opentsdb
LimitNOFILE=65535
Environment='JVMARGS=-DLOG_FILE=/var/log/opentsdb/opentsdb.log -DQUERY_LOG=/var/log/opentsdb/queries.log -XX:+ExitOnOutOfMemoryError -enableassertions -enablesystemassertions'
ExecStart=/usr/bin/tsdb tsd --config /usr/share/opentsdb/etc/opentsdb/opentsdb.conf
Restart=always
StandardOutput=journal
5 changes: 5 additions & 0 deletions opentsdb.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{_localstatedir}/cache/opentsdb
mkdir -p %{buildroot}%{_localstatedir}/log/opentsdb
mkdir -p %{buildroot}%{_localstatedir}/tmp/opentsdb
mkdir -p %{buildroot}%{_datarootdir}/opentsdb/plugins
# TODO: Use alternatives to manage the init script and configuration.

Expand All @@ -77,8 +78,10 @@ rm -rf %{buildroot}
%doc
%{_datarootdir}/opentsdb
%{_bindir}/tsdb
%dir %attr(0755,opentsdb,opentsdb) %{_tmppath}/opentsdb
%dir %attr(0755,opentsdb,opentsdb) %{_localstatedir}/cache/opentsdb
%dir %attr(0755,opentsdb,opentsdb) %{_localstatedir}/log/opentsdb
%dir %attr(0755,opentsdb,opentsdb) %{_localstatedir}/tmp/opentsdb

%changelog

Expand All @@ -91,6 +94,7 @@ if [ $1 -eq 1 ]; then
# we're installing the first version of this package
ln -s %{_datarootdir}/opentsdb/etc/opentsdb /etc/opentsdb
if [ -d /run/systemd/system ]; then
ln -s %{_datarootdir}/opentsdb/etc/systemd/system/opentsdb.service /lib/systemd/system
ln -s %{_datarootdir}/opentsdb/etc/systemd/system/[email protected] /lib/systemd/system
systemctl daemon-reload
else
Expand All @@ -104,6 +108,7 @@ if [ $1 -eq 0 ]; then
# we're removing last version of this package
[ -L /etc/opentsdb ] && rm -f /etc/opentsdb
[ -L /etc/init.d/opentsdb ] && rm -f /etc/init.d/opentsdb
[ -L /lib/systemd/system/opentsdb.service ] && rm -f /lib/systemd/system/opentsdb.service
[ -L /lib/systemd/system/[email protected] ] && rm -f /lib/systemd/system/[email protected]
[ -d /run/systemd/system ] && systemctl daemon-reload
fi
Expand Down

0 comments on commit fc34c0e

Please sign in to comment.