Commit 3af5371c authored by Nirina Malard's avatar Nirina Malard

WIP: Nirina tutorial

parent 5fcc4234
[template-cfg]
filename = instance.cfg.in
md5sum = 289be986f5616b34605e7dc5042b693c
[instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in
md5sum = 54f749de37baef42d202c4d28b6de151
[template_nginx_conf]
_update_hash_filename_ = templates/nginx_conf.in
md5sum = 61dc4c82bf48563228ce4dea6c5c6319
[template_launcher]
_update_hash_filename_ = templates/launcher.in
md5sum = 6cb0d64905ae7fc67277c1bf76b86875
[template_mime_types]
_update_hash_filename_ = templates/mime_types.in
md5sum = 4ef94a7b458d885cd79ba0b930a5727e
[template_index_html]
_update_hash_filename_ = templates/index.html.in
md5sum = d57cb01df5941e139b02a2f7bdabcdc8
[template_graceful]
_update_hash_filename_ = templates/graceful.in
md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2
[template_instance_replicate]
_update_hash_filename_ = instance_replicate.cfg.in
md5sum = 01fc8287b5429d21906a649d1163a51f
...@@ -9,9 +9,15 @@ offline = true ...@@ -9,9 +9,15 @@ offline = true
[profile-common] [profile-common]
nginx_location = {{ nginx_location }} nginx_location = {{ nginx_location }}
dash_location = {{ dash_location }} dash_location = {{ dash_location }}
tar_location = {{ tar_location }}
curl_location = {{ curl_location }}
template_nginx_conf = {{ template_nginx_conf_target }} template_nginx_conf = {{ template_nginx_conf_target }}
template_mime_types = {{ template_mime_types_target }} template_mime_types = {{ template_mime_types_target }}
template_launcher = {{ template_launcher_target }} template_launcher = {{ template_launcher_target }}
template_index_html = {{ template_index_html_target }}
template_graceful = {{ template_graceful_target }}
template_monitor = {{ template_monitor }}
[instance-html5as] [instance-html5as]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
...@@ -23,11 +29,45 @@ context = ...@@ -23,11 +29,45 @@ context =
section parameter_list profile-common section parameter_list profile-common
# partition_ipv6 is the random ipv6 allocated to the local partition # partition_ipv6 is the random ipv6 allocated to the local partition
key partition_ipv6 slap-configuration:ipv6-random key partition_ipv6 slap-configuration:ipv6-random
# slapparameter_dict: dictionary of all parameters
key slapparameter_dict slap-configuration:configuration
jsonkey default_parameter_dict :default-parameters
default-parameters =
{
"title": "Tutorial html5as",
"download_url": "",
"port": 8081,
"monitor-httpd-port": 8197
}
[instance-replicate]
recipe = slapos.recipe.template:jinja2
url = {{ template_instance_replicate }}
output = ${buildout:directory}/${:filename}
filename = instance-replicate-html5as.cfg
context =
section buildout buildout
section parameter_list profile-common
key slapparameter_dict slap-configuration:configuration
jsonkey default_parameter_dict :default-parameters
# User can specify parameter for any of the two instances
default-parameters =
{
"title": "",
"title1": "",
"title2": "",
"download_url": "",
"port1": 8081,
"port2": 8082,
"monitor-httpd-port1": 8197,
"monitor-httpd-port2": 8198
}
[switch-softwaretype] [switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype recipe = slapos.cookbook:switch-softwaretype
RootSoftwareInstance = ${:default} RootSoftwareInstance = ${:default}
default = instance-html5as:output default = instance-html5as:output
replicate = instance-replicate:output
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration
......
...@@ -3,12 +3,19 @@ ...@@ -3,12 +3,19 @@
# Deploy html5as instance # Deploy html5as instance
# #
############################# #############################
# parameter_dict: a dictionary with the default parameters from instance.cfg.in
# replaces the values with the parameters of the instance request if there are any
{% set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %}
[buildout] [buildout]
parts = parts =
nginx_conf nginx_conf
downloader downloader
mime_types mime_types
launcher launcher
nginx-graceful
port-listening-promise
logrotate-entry-nginx
publish-connection-information publish-connection-information
# Define egg directories to be the one from Software Release # Define egg directories to be the one from Software Release
...@@ -18,6 +25,9 @@ eggs-directory = {{ buildout['eggs-directory'] }} ...@@ -18,6 +25,9 @@ eggs-directory = {{ buildout['eggs-directory'] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }} develop-eggs-directory = {{ buildout['develop-eggs-directory'] }}
offline = true offline = true
extends = {{ parameter_list['template_monitor'] }}
# partition tree # partition tree
# / # /
# |- etc/ # |- etc/
...@@ -66,12 +76,11 @@ scgi_temp_path = ${:tmp}/scgi_temp_path ...@@ -66,12 +76,11 @@ scgi_temp_path = ${:tmp}/scgi_temp_path
# List of options for html5as configuration # List of options for html5as configuration
# It will run a simple nginx serving the content of srv/html5as # It will run a simple nginx serving the content of srv/html5as
[html5as] [html5as]
# Options
nb_workers = 2 nb_workers = 2
# Network # Network
ip = {{ partition_ipv6 }} ip = {{ partition_ipv6 }}
port = 8081 port = {{ parameter_dict['port'] }}
access_url = http://[${:ip}]:${:port} access_url = http://[${:ip}]:${:port}
# Paths # Paths
...@@ -89,9 +98,10 @@ path_nginx_conf = ${directory:etc}/nginx.conf ...@@ -89,9 +98,10 @@ path_nginx_conf = ${directory:etc}/nginx.conf
path_mime_types = ${directory:etc}/mime_types path_mime_types = ${directory:etc}/mime_types
# Binaries # Binaries
path_shell = {{ parameter_list['dash_location'] }}/bin/dash path_shell = {{ parameter_list['dash_location'] }}/bin/dash
curl-binary = {{ parameter_list['curl_location'] }}/bin/curl
tar-binary = {{ parameter_list['tar_location'] }}/bin/tar
# Executables # Executables
bin_launcher = ${basedirectory:script}/launcher bin_launcher = ${basedirectory:service}/launcher
# Utils # Utils
path_nginx = {{ parameter_list['nginx_location'] }}/sbin/nginx path_nginx = {{ parameter_list['nginx_location'] }}/sbin/nginx
...@@ -120,11 +130,98 @@ context = ...@@ -120,11 +130,98 @@ context =
section param_html5as html5as section param_html5as html5as
# Simple command to put content in the docroot # Simple command to put content in the docroot
# Command to put content in the docroot
[downloader] [downloader]
recipe = plone.recipe.command recipe = plone.recipe.command
command = rm -r ${html5as:docroot}/*; echo "Hello World!" > ${html5as:docroot}/index.html # Paths that buildout should consider as being managed by this buildout part.
# These will be removed when buildout (re)installs or removes this part.
location = ${html5as:docroot}
# This section will fail if the command fails.
stop-on-error = true
# If a tarball is passed as a parameter in download url
# it's content will be served by the instance.
# If the parameter is not provided it fallback to the default template
command =
URL={{ parameter_dict['download_url'] }};
if [ -n "$URL" ];
then
${html5as:curl-binary} -Lks $URL | ${html5as:tar-binary} xzv -C ${:location} --strip-components 1;
else
cp ${default_index_html:rendered} ${:location}/;
fi
[default_index_html]
recipe = slapos.recipe.template:jinja2
template = {{ parameter_list['template_index_html'] }}
rendered = ${directory:srv}/index.html
title = {{ parameter_dict['title'] }}
context =
key title :title
### Nginx Graceful
[nginx-graceful]
recipe = slapos.recipe.template:jinja2
template = {{ parameter_list['template_graceful'] }}
rendered = ${basedirectory:script}/nginx-graceful
mode = 0700
context =
section param_html5as html5as
# Port Listening checking promise
[port-listening-promise]
<= monitor-promise-base
promise = check_socket_listening
name = nginx-port-listening.py
config-host = ${html5as:ip}
config-port = ${html5as:port}
# Use a port different from the default one in order to be able to
# use it in a SlapOS webrunner or a Theia SlapOS Runner
[monitor-instance-parameter]
monitor-httpd-port = {{ parameter_dict['monitor-httpd-port'] }}
# Monitor Stack also provides logrotate stack. We only need to extend
# the logrotate-entry-base defined in instance-logrotate-base.cfg.in .
# More parameters can be added following the logrotate-entry-base section
[logrotate-entry-nginx]
<= logrotate-entry-base
name = nginx
log = ${html5as:path_access_log} ${html5as:path_error_log}
post = kill -USR1 $(cat ${html5as:path_pid})
# Publish nginx address
[publish-connection-information] [publish-connection-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
# By extending monitor publish, all the section deploying monitoring will
# be deployed. The parameters needed for accessing monitoring will be published
<= monitor-publish
server_url = ${html5as:access_url} server_url = ${html5as:access_url}
title = Title {{ parameter_dict['title'] }}!
# Add dependency to the promise so that frontend sections are processed
# and there is no need to declare the new part in buildout:parts
server-cdn-url = ${html5as-frontend-promise:url}
# Request a CDN entry to master
[html5as-frontend]
# Extend slap-connnection to get the credentials for the request
<= slap-connection
# Recipe used to make requests
recipe = slapos.cookbook:requestoptional
name = HTML5AS frontend
# Specify the software url of the frontend software release
software-url = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
# It is not a dedicated instance but an instance allocated on a shared instance
slave = true
config-url = ${html5as:access_url}
config-https-only = true
# The parameter expected to be received from the request are listed here.
return = domain secure_access
# Add a promise to make sure the cdn is properly configured
[html5as-frontend-promise]
<= monitor-promise-base
promise = check_url_available
name = html5as-http-frontend.py
url = ${html5as-frontend:connection-secure_access}
config-url = ${:url}
config-check-secure = 1
{% set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %}
# Standard buildout section
[buildout]
parts =
publish-connection-information
eggs-directory = {{ buildout['eggs-directory'] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }}
offline = true
################################
# Sections to Request instances
################################
# Macro section sharing request parameters
[instance-request-base]
<= slap-connection
recipe = slapos.cookbook:request
# It is the same software as the current one
software-url = ${slap-connection:software-release-url}
# We want the default behaviour
software-type = default
# What parameter are neede to be retrieved
return = server_url server-cdn-url monitor-setup-url
# Provided parameters
config-title = {{ parameter_dict['title'] }}
config-download_url = {{ parameter_dict['download_url'] }}
# Request a normal html5as instance
[instance-1]
<= instance-request-base
# Name of the instance
name = instance-html5as-1
# Port and title can be configured by instance
config-port = {{ parameter_dict['port1'] }}
config-title = {{ parameter_dict['title1'] }}
config-monitor-httpd-port = {{ parameter_dict['monitor-httpd-port1'] }}
# Request a second html5as instance
[instance-2]
<= instance-request-base
# Name of the instance
name = instance-html5as-2
config-port = {{ parameter_dict['port2'] }}
config-title = {{ parameter_dict['title2'] }}
config-monitor-httpd-port = {{ parameter_dict['monitor-httpd-port2'] }}
# Publish information to connect to the two instances
[publish-connection-information]
recipe = slapos.cookbook:publish
instance-1-server_url = ${instance-1:connection-server_url}
instance-1-server-cdn-url = ${instance-1:connection-server-cdn-url}
instance-1-server-monitor-setup-url = ${instance-1:connection-monitor-setup-url}
instance-2-server_url = ${instance-2:connection-server_url}
instance-2-server-cdn-url = ${instance-1:connection-server-cdn-url}
instance-2-server-monitor-setup-url = ${instance-1:connection-monitor-setup-url}
software_name=html5as-base
software_release_uri=~/srv/project/slapos/software/$software_name/software.cfg
slapos supply $software_release_uri slaprunner
slapos request $software_name'_1' $software_release_uri --parameters \ title='John Doe' \
download_url='https://lab.nexedi.com/nexedi/converse.js/-/archive/nexedi-v4.2.0/converse.js-nexedi-v4.2.0.tar.gz'
port=8086
\ No newline at end of file
[buildout] [buildout]
extends = extends =
#buildout.hash.cfg is used for automated hashcalcul
#instance files by calling update-hash
buildout.hash.cfg
# "slapos" stack describes basic things needed for 99.9% of SlapOS Software # "slapos" stack describes basic things needed for 99.9% of SlapOS Software
# Releases # Releases
../../stack/slapos.cfg ../../stack/slapos.cfg
# Extend monitoring stack to provide necessary tools for monitoring
../../stack/monitor/buildout.cfg
# Extend here component profiles, like openssl, apache, mariadb, curl... # Extend here component profiles, like openssl, apache, mariadb, curl...
# Or/and extend a stack (lamp, tomcat) that does most of the work for you # Or/and extend a stack (lamp, tomcat) that does most of the work for you
# In this example we extend needed components for html5as. # In this example we extend needed components for html5as.
../../component/nginx/buildout.cfg ../../component/nginx/buildout.cfg
../../component/dash/buildout.cfg ../../component/dash/buildout.cfg
../../component/tar/buildout.cfg
../../component/curl/buildout.cfg
parts = parts =
# Call installation of slapos.cookbook egg defined in stack/slapos.cfg (needed # Call installation of slapos.cookbook egg defined in stack/slapos.cfg (needed
...@@ -22,47 +29,53 @@ parts = ...@@ -22,47 +29,53 @@ parts =
# Download instance.cfg.in (buildout profile used to deployment of instance), # Download instance.cfg.in (buildout profile used to deployment of instance),
# replace all {{ foo_bar }} parameters by real values # replace all {{ foo_bar }} parameters by real values
# The recipe, template and mode are fetched from jijna-template # The recipe, template and mode are fetched from jijna-template
[template-cfg] [template-cfg]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
output = ${buildout:directory}/template.cfg rendered = ${buildout:directory}/template.cfg
url = ${:_profile_base_location_}/${:filename} template = ${:_profile_base_location_}/${:filename}
filename = instance.cfg.in
md5sum = 861e7ce5d65252067d31c7325c97917d
context = context =
section buildout buildout section buildout buildout
key nginx_location nginx:location key nginx_location nginx:location
key dash_location dash:location key dash_location dash:location
key tar_location tar:location
key curl_location curl:location
key template_nginx_conf_target template_nginx_conf:target key template_nginx_conf_target template_nginx_conf:target
key template_mime_types_target template_mime_types:target key template_mime_types_target template_mime_types:target
key template_launcher_target template_launcher:target key template_launcher_target template_launcher:target
key template_instance_html5as_target instance_html5as:target key template_instance_html5as_target instance_html5as:target
key template_index_html_target template_index_html:target
key template_graceful_target template_graceful:target
key template_instance_replicate template_instance_replicate:target
key template_monitor monitor2-template:output
# Download instance_html5as.cfg.in [download-base]
[instance_html5as]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_} url = ${:_profile_base_location_}/${:_update_hash_filename_}
_update_hash_filename_ = instance_html5as.cfg.in mode = 0644
md5sum = 2c2bcd723694bc88df13c139c96e8bad
[instance_html5as]
<= download-base
[template_nginx_conf] [template_nginx_conf]
recipe = slapos.recipe.build:download <= download-base
url = ${:_profile_base_location_}/${:_update_hash_filename_}
_update_hash_filename_ = templates/nginx_conf.in
md5sum = 61dc4c82bf48563228ce4dea6c5c6319
[template_launcher] [template_launcher]
recipe = slapos.recipe.build:download <= download-base
url = ${:_profile_base_location_}/${:_update_hash_filename_}
_update_hash_filename_ = templates/launcher.in
md5sum = 6cb0d64905ae7fc67277c1bf76b86875
[template_mime_types] [template_mime_types]
recipe = slapos.recipe.build:download <= download-base
url = ${:_profile_base_location_}/${:_update_hash_filename_}
_update_hash_filename_ = templates/mime_types.in
md5sum = 4ef94a7b458d885cd79ba0b930a5727e
[extra-eggs] [extra-eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = eggs =
plone.recipe.command plone.recipe.command
[template_index_html]
<= download-base
[template_graceful]
<= download-base
[template_instance_replicate]
<= download-base
#! {{ param_html5as['path_shell'] }}
# BEWARE: This file is operated by slapos node
# BEWARE: It will be overwritten automatically
# Run graceful
exec kill -s SIGHUP $(cat {{ param_html5as['path_pid'] }})
{% if title %}
<h1>{{ title }}</h1>
{% endif %}
<p>Hello World</p>
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