Commit 35db1de7 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Dmitry Blinov

create pwrrt service

parent 183a217c
......@@ -15,10 +15,23 @@ scripts = ${:etc}/run
services = ${:etc}/service
ssl = ${:etc}/ssl
auth = ${:tmp}/auth
pwrp = ${buildout:directory}/pwrp
ca-dir = ${:srv}/ssl
novnc-conf = ${:etc}/novnc
prerm = ${:etc}/prerm
pwrp = ${buildout:directory}/pwrp
common = ${:pwrp}/common
x86-64-linux = ${:pwrp}/x86_64_linux
inc = ${:common}/inc
load = ${:common}/load
log = ${:common}/log
loghist = ${:common}/loghist
db = ${:common}/db
web = ${:common}/web
exe = ${:x86-64-linux}/exe
lib = ${:x86-64-linux}/lib
obj = ${:x86-64-linux}/obj
lis = ${:x86-64-linux}/lis
[certificate-authority]
recipe = slapos.cookbook:certificate_authority
......@@ -123,6 +136,7 @@ input = inline:#!/bin/bash
export PWR_BUS_ID=999
export DISPLAY=${xserver:display}
export LD_LIBRARY_PATH={{ ld_library_path }}
export TMPDIR=${directory:tmp}
if [ "$PS1" ]; then
eval `dircolors -b`
......@@ -165,6 +179,25 @@ context =
raw pwr_bus_id 999
raw java_location {{ java_location }}
[pwrrt-wrapper]
recipe = slapos.recipe.template:jinja2
rendered = ${directory:bin}/pwrrt
extensions = jinja2.ext.do
mode = 0744
template = {{ template_pwrrt }}
context =
key tmp_directory directory:tmp
key pwrp_profile pwrp-profile:rendered
[pwrrt-service]
recipe = slapos.cookbook:wrapper
command-line = ${pwrrt-wrapper:rendered} start
wrapper-path = ${directory:services}/pwrrt
hash-existing-files = ${buildout:directory}/software_release/buildout.cfg
environment =
LD_LIBRARY_PATH={{ ld_library_path }}
[request-slave-frontend]
recipe = slapos.cookbook:requestoptional
server-url = ${slap-connection:server-url}
......@@ -206,6 +239,7 @@ parts =
novnc-promise
proview-environment
bash-profile
pwrrt-service
# Complete parts with sections
{{ part_list | join('\n ') }}
......
......@@ -43,6 +43,7 @@ extra-context =
raw proview_compile_dir ${pwr:location}__compile__/pwr
raw ld_library_path ${pwr:ld-library-path}
raw pwrp_profile ${template-pwrp-profile:location}/${template-pwrp-profile:filename}
raw template_pwrrt ${template-pwrrt:location}/${template-pwrrt:filename}
mode = 0644
[slap-configuration]
......
bus_id="{{ pwr_bus_id }}"
if [ -e /etc/proview.cnf ]; then
bus_id=`eval cat /etc/proview.cnf | grep "\\bqcomBusId\\b" | awk '{print $2}'`
if [ -e {{ base_directory }}/etc/proview.cnf ]; then
bus_id=`eval cat {{ base_directory }}/etc/proview.cnf | grep "\\bqcomBusId\\b" | awk '{print $2}'`
fi
if [ -e /etc/proview.cnf ]; then
web_dir=`eval cat /etc/proview.cnf | grep "\\bwebDirectory\\b" | awk '{print $2}'`
if [ -e {{ base_directory }}/etc/proview.cnf ]; then
web_dir=`eval cat {{ base_directory }}/etc/proview.cnf | grep "\\bwebDirectory\\b" | awk '{print $2}'`
fi
export PWR_BUS_ID=$bus_id
......@@ -39,11 +39,10 @@ export jdk_home={{ java_location }}/bin
PATH=$PATH:$pwr_exe:$pwrp_exe:$jdk_home
#symbols to define start/stop commands for PWR
alias pwr_stop='/etc/init.d/pwr stop'
alias pwr_stop.sh="/etc/init.d/pwr stop"
alias pwr_start="/etc/init.d/pwr start"
alias pwr="/etc/init.d/pwr"
alias boot="/usr/bin/sudo /sbin/reboot"
alias pwr_stop='{{ base_directory }}/bin/pwr stop'
alias pwr_stop.sh="{{ base_directory }}/bin/pwr stop"
alias pwr_start="{{ base_directory }}/bin/pwr start"
alias pwr="{{ base_directory }}/bin/pwr"
if [ -e $pwrp_exe/profile ]; then
source $pwrp_exe/profile
......
#
# Start script for Proview runtime
#
TMPDIR={{ tmp_directory }}
wrapper="{{ tmp_directory }}/rt_ini_wrapper"
killer="{{ tmp_directory }}/pwr_killer"
. {{ pwrp_profile }}
umask 002
create_wrapper()
{
if [ ! -e $wrapper ] ; then
echo "#!/bin/bash" > $wrapper
echo "source {{ pwrp_profile }}" >> $wrapper
echo "umask 002" >> $wrapper
echo "\$pwr_exe/rt_ini \$* &" >> $wrapper
chmod a+rx $wrapper
if [ ! -e $wrapper ] ;then
echo "$wrapper not writable, check permissions"
exit
fi
fi
}
create_killer()
{
echo "#!/bin/bash" > $killer
echo "source {{ pwrp_profile }}" >> $killer
echo "umask 002" >> $killer
echo "`ps ax | grep "rt_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "rs_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "ra_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "sev_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "opc_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "plc_" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "`ps ax | grep "jpwr.rt" | awk '{ print "kill -9 "$1}'`" >> $killer
echo "eval `ipcs -s|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm sem %s;", $2}'`" >> $killer
echo "eval `ipcs -q|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm msg %s;", $2}'`" >> $killer
echo "eval `ipcs -m|grep ^0x|grep "[ \t]pwrp[ \t]"|awk '{printf "ipcrm shm %s;", $2}'`" >> $killer
echo "if [ -e $pwrp_exe/pwrp_stop.sh ]; then" >> $killer
echo " source $pwrp_exe/pwrp_stop.sh" >> $killer
echo "fi" >> $killer
echo "rm {{ tmp_directory }}/pwr*\$PWR_BUS_ID" >> $killer
chmod a+rx $killer
if [ ! -e $killer ] ;then
echo "$killer not writable, check permissions"
exit
fi
}
pwr_start()
{
create_wrapper
$wrapper
}
pwr_stop()
{
create_wrapper
$wrapper -s
if [ -e $pwrp_exe/pwrp_stop.sh ]; then
source $pwrp_exe/pwrp_stop.sh
fi
while [ "`ps aux | grep -v grep | grep rt_`" != "" ] ; do sleep 1; done
}
pwr_reload()
{
$pwr_exe/rt_ini_wrapper -r
}
pwr_kill()
{
create_killer
$killer
}
case "$1"
in
start)
echo "Start Proview Runtime Environment."
pwr_start
echo "Done."
;;
stop)
echo "Stop Proveiw Runtime Environment."
pwr_stop
echo "Done."
;;
restart)
echo "Restart Proview Runtime Environment."
echo "Closing down..."
pwr_stop
sleep 1
echo "Starting..."
pwr_start
echo "Done."
;;
reload)
echo "Reload Proview Runtime Environment"
pwr_reload
echo "Done."
;;
kill)
echo "Remove all processes and resources for Proview Runtime Environment"
pwr_kill
echo "Done."
;;
reset)
echo "Remove all processes and resources for Proview Runtime Environment"
pwr_kill
echo "Done."
;;
*)
echo " pwr Start and stop Proview Runtime Environment" >&2
echo "" >&2
echo " Usage:" >&2
echo " pwr start|stop|restart|reload|reset" >&2
echo "" >&2
echo " start Start Runtime environment" >&2
echo " stop Stop Runtime environment" >&2
echo " restart First stop and then start Runtime environment" >&2
echo " reload Soft restart of Runtime environment" >&2
echo " reset Remove all processes and resources" >&2
echo "" >&2
exit 1
;;
esac
exit 0
......@@ -44,14 +44,19 @@ mode = 0644
[template-proview-r]
<= download-base
md5sum = 7811559de2118066e3da524e43bd5182
md5sum = a104dfc928552d2fdb4af52108230b47
filename = instance-proview-r.cfg.jinja2.in
[template-pwrp-profile]
<= download-base
md5sum = 34b0c503d786fc59317a761175ddfc3f
md5sum = f980d5a843b8e93287dc704b26e413f3
filename = pwrp_profile.in
[template-pwrrt]
<= download-base
md5sum = d53e00e3e2e249dd16fdba00e881ce01
filename = pwrrt.in
[versions]
numpy = 1.16.4
#websockify = 0.6.1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment