diff --git a/component/helloweb/buildout.cfg b/component/helloweb/buildout.cfg index e0b8f89d0c79b85754e4bad47e5cb233f979dda1..9b32b966a861e4a0e469ff40136e8e0a2b05a512 100644 --- a/component/helloweb/buildout.cfg +++ b/component/helloweb/buildout.cfg @@ -4,7 +4,7 @@ extends = ../git/buildout.cfg parts = - helloweb + helloweb-python # repository with examples @@ -12,16 +12,17 @@ parts = recipe = slapos.recipe.build:gitclone git-executable = ${git:location}/bin/git repository = https://lab.nexedi.com/nexedi/helloweb.git -revision = 88d517131e75929f79a4d36de4124dab4521614a +revision = 686dd5dd623728750ec30514173a7be36fab3a06 location = ${buildout:parts-directory}/helloweb +# -*- python -*- [helloweb-egg] recipe = zc.recipe.egg:develop egg = helloweb setup = ${helloweb-repository:location}/python/ -[helloweb] +[helloweb-python] recipe = zc.recipe.egg:scripts eggs = ${helloweb-egg:egg} -scripts = helloweb +scripts = helloweb=helloweb-python diff --git a/software/helloworld/instance.cfg.in b/software/helloworld/instance.cfg.in index e57740c2a06d483c4d344639536ec24292e26617..223ffddcb4c302d6c4139cd0a8b768632908a038 100644 --- a/software/helloworld/instance.cfg.in +++ b/software/helloworld/instance.cfg.in @@ -6,8 +6,6 @@ [buildout] parts = directory - helloweb - helloweb-promise publish-connection-parameter # Define egg directories to be the one from Software Release @@ -70,31 +68,56 @@ log = ${:var}/log # 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} -port = 7777 # full URL - for convenience url = http://[${:ipv6}]:${:port} # the service will log here -logfile = ${directory:log}/helloweb.log +logfile = ${directory:log}/helloweb-${:kind}.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'] }}/helloweb --logfile ${helloweb:logfile} + {{ buildout['bin-directory'] }}/helloweb-${:kind} --logfile ${:logfile} ${:ipv6} ${:port} ${instance-parameter:configuration.name} # 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 +wrapper-path = ${directory:service}/helloweb-${:kind} # promise, that checks that helloweb service is alive [helloweb-promise] recipe = slapos.cookbook:check_port_listening -path = ${directory:promise}/helloweb -hostname= ${helloweb:ipv6} -port = ${helloweb:port} +path = ${directory:promise}/helloweb-${:kind} + +{# 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 }} +hostname= ${helloweb-{{ kind }}:ipv6} +port = {{ 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. @@ -103,4 +126,6 @@ port = ${helloweb:port} [publish-connection-parameter] recipe = slapos.cookbook:publish name = Hello ${instance-parameter:configuration.name}! -url = ${helloweb:url} +{%- for kind in service_list %} +url.{{ kind }} = ${helloweb-{{ kind }}:url} +{%- endfor %} diff --git a/software/helloworld/software.cfg b/software/helloworld/software.cfg index 8c723528e526ab165aadb2b026eb0d3802ea4112..75ff8b695b8290a2e8d42ad42dcdd7a37d2aecb8 100644 --- a/software/helloworld/software.cfg +++ b/software/helloworld/software.cfg @@ -19,8 +19,8 @@ parts = # instance instance-profile -# build helloweb program - helloweb +# build helloweb programs + helloweb-python # Download instance.cfg.in (buildout profile used to deployment of instance), @@ -31,7 +31,8 @@ recipe = slapos.recipe.template:jinja2 template = ${:_profile_base_location_}/instance.cfg.in rendered = ${buildout:directory}/instance.cfg # MD5 checksum can be skipped for development (easier to develop), but must be filled for production -md5sum = f282976950be0377dcb08c4f3513b4a1 +md5sum = dc11d4d87edda76189ddd88a35265f05 mode = 0644 +extensions = jinja2.ext.do context = section buildout buildout