This is an automated email from the ASF dual-hosted git repository.
zrhoffman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new a88faf9ebc Tm sytemd unit (#7735)
a88faf9ebc is described below
commit a88faf9ebc64b548d9418384e9612cb56854062a
Author: Ashish P <[email protected]>
AuthorDate: Tue Aug 22 09:01:56 2023 -0600
Tm sytemd unit (#7735)
* adding TM systemd unit
* Add license traffic_monitor.service.j2
---------
Co-authored-by: Ashish Paudyal <[email protected]>
---
.../roles/traffic-monitor/defaults/main.yml | 4 +++
.../traffic-monitor/tasks/traffic_monitor.yml | 12 +++++++--
.../templates/traffic_monitor.service.j2 | 31 ++++++++++++++++++++++
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/infrastructure/ansible/roles/traffic-monitor/defaults/main.yml
b/infrastructure/ansible/roles/traffic-monitor/defaults/main.yml
index 09b2643688..f6bb4b9eea 100644
--- a/infrastructure/ansible/roles/traffic-monitor/defaults/main.yml
+++ b/infrastructure/ansible/roles/traffic-monitor/defaults/main.yml
@@ -18,6 +18,10 @@ tm_pkg_name: "{% if tm_version is defined and tm_version !=
omit %}{{ 'traffic_m
# Traffic Monitor installation information
tm_base_dir: '/opt/traffic_monitor'
tm_log_dir: "{{ tm_base_dir}}/var/log"
+tm_exec_path: "{{ tm_base_dir}}/bin/traffic_monitor"
+tm_to_config: "{{ tm_base_dir}}/conf/traffic_ops.cfg"
+tm_config: "{{ tm_base_dir}}/conf/traffic_monitor.cfg"
+tm_pid_file: "{{ tm_base_dir}}/var/run/traffic_monitor"
# Local OS User for the Traffic Monitor process
tm_user: traffic_monitor
diff --git
a/infrastructure/ansible/roles/traffic-monitor/tasks/traffic_monitor.yml
b/infrastructure/ansible/roles/traffic-monitor/tasks/traffic_monitor.yml
index 55a9105ffc..ff7540e14e 100644
--- a/infrastructure/ansible/roles/traffic-monitor/tasks/traffic_monitor.yml
+++ b/infrastructure/ansible/roles/traffic-monitor/tasks/traffic_monitor.yml
@@ -28,7 +28,7 @@
- name: Copy traffic_monitor config
template:
src: traffic_monitor.cfg.j2
- dest: /opt/traffic_monitor/conf/traffic_monitor.cfg
+ dest: "{{ tm_config }}"
mode: 0600
owner: traffic_monitor
group: traffic_monitor
@@ -38,13 +38,21 @@
- name: Copy traffic_ops config
template:
src: traffic_ops.cfg.j2
- dest: /opt/traffic_monitor/conf/traffic_ops.cfg
+ dest: "{{ tm_to_config }}"
mode: 0600
owner: traffic_monitor
group: traffic_monitor
notify: Restart Traffic Monitor
become: yes
+- name: Copy the traffic-monitor systemd unit file
+ template:
+ src: traffic_monitor.service.j2
+ dest: /etc/systemd/system/traffic_monitor.service
+ owner: root
+ group: root
+ mode: 0644
+
- name: Enable traffic_monitor
service:
name: traffic_monitor
diff --git
a/infrastructure/ansible/roles/traffic-monitor/templates/traffic_monitor.service.j2
b/infrastructure/ansible/roles/traffic-monitor/templates/traffic_monitor.service.j2
new file mode 100644
index 0000000000..b2f4227b56
--- /dev/null
+++
b/infrastructure/ansible/roles/traffic-monitor/templates/traffic_monitor.service.j2
@@ -0,0 +1,31 @@
+{#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#}
+[Unit]
+Description=Traffic Monitor is a HTTP service that polls the health of caches
and provide status to Trafffic Routers.
+Wants=systemd-udev-settle.service
+After=syslog.target network.target systemd-udev-settle.service
+
+[Service]
+Type=simple
+ExecStart={{ tm_exec_path }} --opsCfg {{ tm_to_config }} --config {{ tm_config
}}
+Restart=on-failure
+RestartSec=5s
+LimitNOFILE=1000000
+PIDFile={{ tm_pid_file }}
+TimeoutStopSec=5s
+ExecReload={{ tm_exec_path }} config reload
+KillMode=process
+
+[Install]
+WantedBy=multi-user.target