Skip to content

Commit

Permalink
add systemd service, log folder and link binary
Browse files Browse the repository at this point in the history
  • Loading branch information
C8Y-Mario committed Oct 31, 2022
1 parent 462f42c commit cda1dec
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json

# Pyre type checker
.pyre/
.idea/modules.xml
.idea/
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Source: te-modbus-plugin
Section: python
Priority: extra
Maintainer: Mario Heidenreich <mario.heidenreich@softwareag.com>
Build-Depends: debhelper (>= 9), dh-virtualenv (>= 0.8)
Build-Depends: debhelper (>= 9.2), dh-virtualenv (>= 0.8)
Standards-Version: 3.9.5

Package: te-modbus-plugin
Architecture: any
Pre-Depends: dpkg (>= 1.16.1), tedge_agent (>= 0.7.7), python (>= 3.8.0) | python3 (>= 3.8.0), ${misc:Pre-Depends}
Pre-Depends: dpkg (>= 1.16.1), python (>= 3.8.0) | python3 (>= 3.8.0), ${misc:Pre-Depends}
Depends: ${misc:Depends}
Description: A short summary of what this is.
Further indented lines can contain extra information.
Expand Down
11 changes: 11 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

#DEBHELPER#

# Enable the service only if systemctl is available
if command -v systemctl >/dev/null; then
systemctl start te-modbus-plugin.service
systemctl enable te-modbus-plugin.service
fi
3 changes: 2 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/make -f

%:
dh $@ --with python-virtualenv
dh $@ --with python-virtualenv --with systemd

#DEBHELPER#

1 change: 1 addition & 0 deletions debian/te-modbus-plugin.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var/log/te-modbus-plugin
2 changes: 2 additions & 0 deletions debian/te-modbus-plugin.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config/devices.toml etc/tedge/plugins/modbus/
config/modbus.toml etc/tedge/plugins/modbus/
1 change: 1 addition & 0 deletions debian/te-modbus-plugin.links
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opt/venvs/te-modbus-plugin/bin/te-modbus-reader usr/sbin/te-modbus-plugin
10 changes: 10 additions & 0 deletions debian/te-modbus-plugin.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Modbus Data Reader

[Service]
User=root
ExecStart=/usr/sbin/te-modbus-plugin -l /var/log/te-modbus-plugin/modbus.log
Restart=on-failure

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
setup(
name='te-modbus-reader',
version='0.1',
description='Modbus plugin for ',
url='http://github.com/trstringer/python3-random-quote',
description='Modbus plugin for thin-edge',
url='https://github.com/thin-edge/modbus-plugin',
author='Software AG ♥ thin-edge.io',
author_email='github@trstringer.com',
author_email='info@thin-edge.io',
license='MIT',
install_requires=[
'paho-mqtt~=1.6.1',
Expand All @@ -19,6 +19,7 @@
'tomli~=2.0.1',
'pyserial-asyncio'],
packages=find_packages(),
data_files=[('config/devices.toml', ['config/devices.toml']), ('config/modbus.toml', ['config/modbus.toml'])],
entry_points=dict(
console_scripts=['te-modbus-reader=modbus_reader.reader:main']
)
Expand Down
3 changes: 1 addition & 2 deletions systemd/te-modbus-plugin.service
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[Unit]
Description=Modbus Data Reader
After=tedge-agent.service

[Service]
User=root
ExecStart=/usr/bin/python3 /etc/tedge/reader.py
ExecStart=/usr/sbin/te-modbus-plugin -l /var/log/te-modbus-plugin/modbus.log
Restart=on-failure

[Install]
Expand Down

0 comments on commit cda1dec

Please sign in to comment.