mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-12-22 23:22:16 +03:00
ahenk service
This commit is contained in:
parent
3c217ff110
commit
3ccb1d1d05
10 changed files with 141 additions and 0 deletions
29
debian/postinst
vendored
Normal file
29
debian/postinst
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
# postinst script for ahenk
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
|
||||
systemctl --system daemon-reload
|
||||
systemctl enable ahenk.service
|
||||
|
||||
update-rc.d ahenk defaults
|
||||
/etc/init.d/ahenk start
|
||||
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
45
etc/init.d/ahenk
Normal file
45
etc/init.d/ahenk
Normal file
|
@ -0,0 +1,45 @@
|
|||
#! /bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ahenk
|
||||
# Required-Start: $remote_fs $syslog $network
|
||||
# Required-Stop: $remote_fs $syslog $network
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Manages ahenk service.
|
||||
# Description: Debian init script for the ahenk executables
|
||||
# scheduler
|
||||
### END INIT INFO
|
||||
#
|
||||
# Author: S Suleyman Arslan <sarslan@innova.com.tr>
|
||||
#
|
||||
|
||||
# Activate the python virtual environment
|
||||
# . /path_to_virtualenv/activate
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting server"
|
||||
# Start the daemon
|
||||
#python $AHENKDPATH start
|
||||
systemctl start ahenk.service
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping server"
|
||||
systemctl stop ahenk.service
|
||||
;;
|
||||
restart)
|
||||
echo "Restarting server"
|
||||
systemctl restart ahenk.service
|
||||
;;
|
||||
status)
|
||||
echo "Server Status"
|
||||
# Status of the daemon
|
||||
systemctl status ahenk.service
|
||||
;;
|
||||
*)
|
||||
# Refuse to do other stuff
|
||||
echo "Usage: /etc/init.d/ahenk.sh {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
12
lib/systemd/system/ahenk.service
Normal file
12
lib/systemd/system/ahenk.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Starts Ahenk at system startup
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=python "/opt/ahenk/ahenkd.py start"
|
||||
ExecStop=python "/opt/ahenk/ahenkd.py stop"
|
||||
PIDFile=/var/run/ahenkd.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
0
opt/ahenk/ahenkd.py
Normal file
0
opt/ahenk/ahenkd.py
Normal file
7
opt/ahenk/api/service/ps_util.py
Normal file
7
opt/ahenk/api/service/ps_util.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
import psutil
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
34
opt/ahenk/base/plugin/AbstractPlugin.py
Normal file
34
opt/ahenk/base/plugin/AbstractPlugin.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
import imp,os
|
||||
"""
|
||||
class AbstractPlugin(object):
|
||||
This is base class for plugins
|
||||
def __init__(self, arg):
|
||||
super(AbstrackPlugin, self).__init__()
|
||||
self.arg = arg
|
||||
"""
|
||||
pluginFolder = '/home/ismail/devzone/workspace/LiderAhenk/ahenk/opt/ahenk/plugins'
|
||||
mainModule = 'main'
|
||||
|
||||
def getPlugins():
|
||||
plugins = []
|
||||
possibleplugins = os.listdir(pluginFolder)
|
||||
for i in possibleplugins:
|
||||
location = os.path.join(pluginFolder, i)
|
||||
if not os.path.isdir(location) or not mainModule + ".py" in os.listdir(location):
|
||||
continue
|
||||
info = imp.find_module(mainModule, [location])
|
||||
plugins.append({"name": i, "info": info})
|
||||
return plugins
|
||||
|
||||
def loadPlugin(plugin):
|
||||
return imp.load_module(mainModule, *plugin["info"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
for i in getPlugins():
|
||||
print("Loading plugin " + i["name"])
|
||||
plugin = loadPlugin(i)
|
||||
plugin.run("tabisi")
|
8
opt/ahenk/plugins/plugin1/main.py
Normal file
8
opt/ahenk/plugins/plugin1/main.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
|
||||
|
||||
def run(val):
|
||||
print "oo yeah plugin1 " + str(val)
|
BIN
opt/ahenk/plugins/plugin1/main.pyc
Normal file
BIN
opt/ahenk/plugins/plugin1/main.pyc
Normal file
Binary file not shown.
6
opt/ahenk/plugins/plugin2/main.py
Normal file
6
opt/ahenk/plugins/plugin2/main.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
def run(val):
|
||||
print "oo yeah plugin2 " + str(val)
|
BIN
opt/ahenk/plugins/plugin2/main.pyc
Normal file
BIN
opt/ahenk/plugins/plugin2/main.pyc
Normal file
Binary file not shown.
Loading…
Reference in a new issue