Provide systemd files
+ move example cfg from etc/ to cfg/ Change-Id: I437b3e2aaca55539ff110f5a46e411b34e0a0b9c Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/21319 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
parent
0c1a63538c
commit
9b33e07260
59
etc/secop-generator
Executable file
59
etc/secop-generator
Executable file
@ -0,0 +1,59 @@
|
|||||||
|
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# *****************************************************************************
|
||||||
|
# Copyright (c) 2015-2019 by the authors, see LICENSE
|
||||||
|
#
|
||||||
|
# This program 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 2 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program 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
|
||||||
|
# this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
#
|
||||||
|
# Module authors:
|
||||||
|
# Alexander Lenz <alexander.lenz@frm2.tum.de>
|
||||||
|
# Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
|
||||||
|
#
|
||||||
|
# *****************************************************************************
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import fnmatch
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
from secop.lib import getGeneralConfig
|
||||||
|
|
||||||
|
def main():
|
||||||
|
normal_dir = sys.argv[1]
|
||||||
|
|
||||||
|
global_config = getGeneralConfig()
|
||||||
|
config_dir = global_config['confdir']
|
||||||
|
|
||||||
|
secop_unit = '/lib/systemd/system/secop@.service'
|
||||||
|
wants_dir = normal_dir + '/secop.target.wants'
|
||||||
|
|
||||||
|
all_servers = [base for (base, ext) in
|
||||||
|
map(path.splitext, os.listdir(config_dir)) if ext == '.cfg']
|
||||||
|
all_servers.sort()
|
||||||
|
|
||||||
|
for srv in all_servers:
|
||||||
|
symlink = '%s/secop@%s.service' % (normal_dir, srv)
|
||||||
|
os.symlink(secop_unit, symlink)
|
||||||
|
|
||||||
|
# the stamp file signals successful run of the generator
|
||||||
|
open(normal_dir + '/secop.stamp', 'w').close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except Exception:
|
||||||
|
pass # don't signal an error here
|
8
etc/secop.target
Normal file
8
etc/secop.target
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Start all SECoP SEC-nodes
|
||||||
|
Requires=network-online.service
|
||||||
|
Wants=network-online.service
|
||||||
|
After=network-online.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
12
etc/secop@.service
Normal file
12
etc/secop@.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=SECoP SEC-node: %i
|
||||||
|
After=network-online.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
ExecStart=/usr/bin/secop-server %I
|
||||||
|
Restart=on-abnormal
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -40,7 +40,7 @@ repodir = path.abspath(path.join(path.dirname(__file__), u'..', u'..'))
|
|||||||
CONFIG = {
|
CONFIG = {
|
||||||
u'piddir': os.path.join(repodir, u'pid'),
|
u'piddir': os.path.join(repodir, u'pid'),
|
||||||
u'logdir': os.path.join(repodir, u'log'),
|
u'logdir': os.path.join(repodir, u'log'),
|
||||||
u'confdir': os.path.join(repodir, u'etc'),
|
u'confdir': os.path.join(repodir, u'cfg'),
|
||||||
u'basedir': repodir,
|
u'basedir': repodir,
|
||||||
} if os.path.exists(os.path.join(repodir, u'.git')) else {
|
} if os.path.exists(os.path.join(repodir, u'.git')) else {
|
||||||
u'piddir': u'/var/run/secop',
|
u'piddir': u'/var/run/secop',
|
||||||
|
15
setup.py
15
setup.py
@ -43,12 +43,19 @@ setup(
|
|||||||
author='Enrico Faulhaber',
|
author='Enrico Faulhaber',
|
||||||
author_email='enrico.faulhaber@frm2.tum.de',
|
author_email='enrico.faulhaber@frm2.tum.de',
|
||||||
description='SECoP Playground core system',
|
description='SECoP Playground core system',
|
||||||
packages=find_packages(),
|
packages=find_packages(exclude=['test']),
|
||||||
package_data={'secop': ['RELEASE-VERSION'] + uis},
|
package_data={'secop': ['RELEASE-VERSION'] + uis},
|
||||||
data_files=[('/etc/init.d', ['etc/secop-server'])],
|
data_files=[
|
||||||
|
('/etc/init.d', ['etc/secop-server']),
|
||||||
|
('/lib/systemd/system-generators', ['etc/secop-generator']),
|
||||||
|
('/lib/systemd/system', ['etc/secop@.service',
|
||||||
|
'etc/secop.target']),
|
||||||
|
('/var/log/secop', []),
|
||||||
|
('/var/run/secop', []),
|
||||||
|
],
|
||||||
scripts=scripts,
|
scripts=scripts,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 6 - Mature',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: Science/Research',
|
'Intended Audience :: Science/Research',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
@ -57,6 +64,8 @@ setup(
|
|||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
'Programming Language :: Python :: 2',
|
'Programming Language :: Python :: 2',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3.6',
|
||||||
'Topic :: Scientific/Engineering',
|
'Topic :: Scientific/Engineering',
|
||||||
'Topic :: Scientific/Engineering :: Human Machine Interfaces',
|
'Topic :: Scientific/Engineering :: Human Machine Interfaces',
|
||||||
'Topic :: Scientific/Engineering :: Physics',
|
'Topic :: Scientific/Engineering :: Physics',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user