Commit b9d11c11 authored by Ivan Tyagov's avatar Ivan Tyagov

Osie runtime slaposify

See merge request nexedi/osie!7
parents 668209d3 f628b543
[instance-profile]
filename = instance.cfg.in
md5sum = b0efa23802f4fa545eaa4e67c83f0b7d
md5sum = 2c3cd3750f71046095d7764ebef4e9e1
#############################
#
# Deploy OSIE coupler instance
# Deploy beremiz' runtime instance
#
#############################
[buildout]
parts =
directory
publish-connection-parameter
beremiz-runtime
# beremiz-runtime-promise
# Define egg directories to be the one from Software Release
# (/opt/slapgrid/...)
......@@ -14,7 +16,6 @@ parts =
eggs-directory = {{ buildout['eggs-directory'] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }}
offline = true
extends = {{ template_monitor }}
[instance-parameter]
......@@ -36,13 +37,14 @@ cert = ${slap-connection:cert-file}
# specify it.
# All possible parameters should have a default.
# In our use case, we are expecting from the user to specify one (optional) parameter: "name". We put the default value here if he doesn't specify it, so that it doesn't crash.
configuration.autostart = 1
configuration.interface = 0.0.0.0
configuration.port = 1502
configuration.port = 61248
configuration.plc_runtime_path = /srv/slapgrid/slappart19/compiled_PLC/
# If our use case requires that the user can specify a mail address so that his instance can mail to him (for example), we can do:
# configuration.mail-address =
# If the user doesn't specify it, it won't break and the recipe can handle it (i.e don't send any mail for example).
# Create all needed directories, depending on your needs
[directory]
recipe = slapos.cookbook:mkdirectory
......@@ -56,68 +58,27 @@ service = ${:etc}/service
# Path of the log directory used by our service (see [helloweb])
log = ${:var}/log
# Create a simple web server that says "hello <configuration.name>" to the web.
[helloweb]
# helloworld service is listening on:
# - global IPv6 address, and
# - fixed port
#
# NOTE because every computer partition is allocated its own global IPv6
# address, it is ok to fix the port - different hello-world instances will have
# different IPv6 addresses and they all will be accessible at the same time.
ipv6 = ${instance-parameter:ipv6-random}
# full URL - for convenience
#url = http://[${:ipv6}]:${:port}
[beremiz-runtime]
# the service will log here
logfile = ${directory:log}/helloweb-${:kind}.log
logfile = ${directory:log}/beremiz-runtime.log
# Actual script that starts the service:
# This recipe will try to "exec" the command-line after separating parameters.
recipe = slapos.cookbook:wrapper
command-line =
{{ buildout['bin-directory'] }}/pythonwitheggs {{ buildout['parts-directory'] }}/osie/eggs/osie_coupler/osie_modbus.py -p ${instance-parameter:configuration.port}
{{ buildout['bin-directory'] }}/pythonwitheggs {{ buildout['directory'] }}/src/beremiz/Beremiz_service.py -a ${instance-parameter:configuration.autostart} -p ${instance-parameter:configuration.port} -i ${instance-parameter:configuration.interface} -x 1 ${instance-parameter:configuration.plc_runtime_path}
# Put this shell script in the "etc/service" directory. Each executable of this
# repository will be started and monitored by supervisord. If a service
# exits/crashes, it will trigger a "bang" and cause a re-run of the instance.
wrapper-path = ${directory:service}/helloweb-${:kind}
wrapper-path = ${directory:service}/beremiz-runtime
# promise, that checks that helloweb service is alive
[helloweb-promise]
[beremiz-runtime-promise]
<= monitor-promise-base
module = check_port_listening
name = helloweb-${:kind}.py
{# macro to instantiate service of `kind` to listen on `port` #}
{% set service_list = [] %}
{% macro hellowebsrv(kind, port) %}
{% do service_list.append(kind) %}
[helloweb-{{ kind }}]
<= helloweb
kind = {{ kind }}
port = {{ port }}
[helloweb-{{ kind }}-promise]
<= helloweb-promise
kind = {{ kind }}
name = beremiz-runtime.py
config-hostname= ${instance-parameter:configuration.interface}
config-port = ${instance-parameter:configuration.port}
{% endmacro %}
# services instantiation
{{ hellowebsrv('python', 7777) }}
# register all services/promises to buildout parts
[buildout]
parts +=
{%- for kind in service_list %}
helloweb-{{ kind }}
helloweb-{{ kind }}-promise
{%- endfor %}
# Publish all the parameters needed for the user to connect to the instance.
# It can be anything: URL(s), password(s), or arbitrary parameters.
......
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