Commit dec7d6d7 authored by Ayush Tiwari's avatar Ayush Tiwari

Hello World: Software type webservice and default

Software type default would be requesting software type webservice
parent d91f7277
[buildout]
parts =
request-helloworld
publish-connection-parameter
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[request-helloworld]
<= slap-connection
recipe = slapos.cookbook:request
name = Hello World
software-url = $${slap-connection:software-release-url}
software-type = webservice
return =
url
sla-computer_guid = $${slap-connection:computer-id}
# Publish parameters acquired from request-helloworld
[publish-connection-parameter]
recipe = slapos.cookbook:publish
url = $${request-helloworld:connection-url}
#############################
#
# Deploy hello-world instance
#
#############################
[buildout]
parts =
directory
hello-world
hello-world-promise
publish-connection-parameter
render-template
# Monitoring parts
certificate-authority
cron
cron-entry-monitor
cron-entry-rss
deploy-index
deploy-settings-cgi
deploy-status-cgi
deploy-status-history-cgi
setup-static-files
certificate-authority
zero-parameters
public-symlink
cgi-httpd-wrapper
cgi-httpd-graceful-wrapper
monitor-promise
monitor-instance-log-access
# Logrotate parts
cron-entry-logrotate
logrotate
logrotate-entry
# Define egg directories to be the one from Software Release
# (/opt/slapgrid/...)
# Always the same.
extends = ${monitor-template:output}
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[instance-parameter]
# Fetch arbitrary parameters defined by the user in SlapOS Master for his instance.
# We use the slapconfiguration recipe with a few parameters (partition id,
# computer id, certificate, etc).
# It will then authenticate to SlapOS Master and fetch the instance parameters.
# The parameters are accessible from $${instance-parameter:configuration.name-of-parameter}
# Always the same. Just copy/paste.
# See docstring of slapos.cookbook:slapconfiguration for more information.
recipe = slapos.cookbook:slapconfiguration
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
configuration.name = John Doe
configuration.title =
configuration.repetition_number =
configuration.port = 7777
# Create all needed directories, depending on your needs
[directory]
recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory}
etc = $${:home}/etc
var = $${:home}/var
bin = $${:home}/bin
srv = $${:home}/srv
# Executables put here will be started but not monitored (for startup scripts)
script = $${:etc}/run/
# Executables put here will be started and monitored (for daemons)
service = $${:etc}/service
# Executables put here will be launched after buildout has completed to see
# if instance is running
promise = $${:etc}/promise/
# Path of the log directory used by our service (see [hello-world])
log = $${:var}/log
data-fold = $${:srv}/data
# Cron directories
cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
# Logrotate directories
backup = $${:srv}/backup
logrotate-backup = $${:backup}/logrotate
logrotate-entries = $${:etc}/logrotate.d
[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:wrapper}
binary = $${directory:service}/crond
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${directory:bin}/cron_simplelogger
log = $${directory:log}/cron.log
[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 * * * *
command = $${logrotate:wrapper}
[logrotate]
recipe = slapos.cookbook:logrotate
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = ${gzip:location}/bin/gzip
gunzip-binary = ${gzip:location}/bin/gunzip
wrapper = $${directory:bin}/logrotate
conf = $${directory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${directory:srv}/logrotate.status
[logrotate-entry]
# Extends logrotate
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = helloworld-logrotate
log = $${directory:log}/log.log
frequency = daily
rotatep-num = 30
sharedscripts = true
notifempty = true
create = true
# Create a simple web server that says "hello <configuration.name>" to the web.
[hello-world]
# 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}
port = $${instance-parameter:configuration.port}
# full URL - for convenience
url = http://[$${:ipv6}]:$${:port}
# the service will log here
logfile = $${directory:log}/hello-world.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 =
${hello-web-bin:rendered} --logfile $${hello-world: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}/hello-world
# promise, that checks that hello-world service is alive
[hello-world-promise]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/hello-world
hostname= $${hello-world:ipv6}
port = $${hello-world:port}
[render-template]
recipe = slapos.recipe.template:jinja2
template = ${template-download:location}/${template-download:filename}
rendered = $${directory:data-fold}/data1.txt
#Why 700 specifically for rendered text file ??
#mode = 640
context =
key name instance-parameter:configuration.name
key title instance-parameter:configuration.title
key repetition_number instance-parameter:configuration.repetition_number
# Publish all the parameters needed for the user to connect to the instance.
# It can be anything: URL(s), password(s), or arbitrary parameters.
# Here we'll just echo back the entered name as instance parameter
[publish-connection-parameter]
recipe = slapos.cookbook:publish
name = Hello $${instance-parameter:configuration.name}!
title = $${instance-parameter:configuration.title}
repetition_number = $${instance-parameter:configuration.repetition_number}
url = $${hello-world:url}
path = $${render-template:rendered}
#############################
#
# Deploy hello-world instance
#
#############################
[buildout]
parts =
directory
hello-world
hello-world-promise
publish-connection-parameter
render-template
# Monitoring parts
certificate-authority
cron
cron-entry-monitor
cron-entry-rss
deploy-index
deploy-settings-cgi
deploy-status-cgi
deploy-status-history-cgi
setup-static-files
certificate-authority
zero-parameters
public-symlink
cgi-httpd-wrapper
cgi-httpd-graceful-wrapper
monitor-promise
monitor-instance-log-access
# Logrotate parts
cron-entry-logrotate
logrotate
logrotate-entry
# Define egg directories to be the one from Software Release
# (/opt/slapgrid/...)
# Always the same.
extends = ${monitor-template:output}
parts =
switch-softwaretype
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[slap-connection]
# For backward compatibility
computer-id = $${slap_connection:computer_id}
partition-id = $${slap_connection:partition_id}
server-url = $${slap_connection:server_url}
software-release-url = $${slap_connection:software_release_url}
key-file = $${slap_connection:key_file}
cert-file = $${slap_connection:cert_file}
[instance-parameter]
# Fetch arbitrary parameters defined by the user in SlapOS Master for his instance.
# We use the slapconfiguration recipe with a few parameters (partition id,
# computer id, certificate, etc).
# It will then authenticate to SlapOS Master and fetch the instance parameters.
# The parameters are accessible from $${instance-parameter:configuration.name-of-parameter}
# Always the same. Just copy/paste.
# See docstring of slapos.cookbook:slapconfiguration for more information.
[slap-parameters]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap_connection:computer_id}
partition = $${slap_connection:partition_id}
url = $${slap_connection:server_url}
key = $${slap_connection:key_file}
cert = $${slap_connection:cert_file}
# Define default parameter(s) that will be used later, in case user didn't
# 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.name = John Doe
# 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).
# Add parameter title to be provided by user/developer, would be None in case user fails to give anything
configuration.title =
configuration.repetition_number =
configuration.port = 7777
# Create all needed directories, depending on your needs
[directory]
recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory}
etc = $${:home}/etc
var = $${:home}/var
bin = $${:home}/bin
srv = $${:home}/srv
# Executables put here will be started but not monitored (for startup scripts)
script = $${:etc}/run/
# Executables put here will be started and monitored (for daemons)
service = $${:etc}/service
# Executables put here will be launched after buildout has completed to see
# if instance is running
promise = $${:etc}/promise/
# Path of the log directory used by our service (see [hello-world])
log = $${:var}/log
data-fold = $${:srv}/data
# Cron directories
cron-entries = $${:etc}/cron.d
crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
# Logrotate directories
backup = $${:srv}/backup
logrotate-backup = $${:backup}/logrotate
logrotate-entries = $${:etc}/logrotate.d
[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:wrapper}
binary = $${directory:service}/crond
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = $${directory:bin}/cron_simplelogger
log = $${directory:log}/cron.log
[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 * * * *
command = $${logrotate:wrapper}
[logrotate]
recipe = slapos.cookbook:logrotate
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = ${gzip:location}/bin/gzip
gunzip-binary = ${gzip:location}/bin/gunzip
wrapper = $${directory:bin}/logrotate
conf = $${directory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${directory:srv}/logrotate.status
[logrotate-entry]
# Extends logrotate
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = helloworld-logrotate
log = $${directory:log}/log.log
frequency = daily
rotatep-num = 30
sharedscripts = true
notifempty = true
create = true
# Create a simple web server that says "hello <configuration.name>" to the web.
[hello-world]
# 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}
port = $${instance-parameter:configuration.port}
# full URL - for convenience
url = http://[$${:ipv6}]:$${:port}
# the service will log here
logfile = $${directory:log}/hello-world.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 =
${hello-web-bin:rendered} --logfile $${hello-world: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}/hello-world
# promise, that checks that hello-world service is alive
[hello-world-promise]
recipe = slapos.cookbook:check_port_listening
path = $${directory:promise}/hello-world
hostname= $${hello-world:ipv6}
port = $${hello-world:port}
[render-template]
recipe = slapos.recipe.template:jinja2
template = ${template-download:location}/${template-download:filename}
rendered = $${directory:data-fold}/data1.txt
#Why 700 specifically for rendered text file ??
#mode = 640
context =
key name instance-parameter:configuration.name
key title instance-parameter:configuration.title
key repetition_number instance-parameter:configuration.repetition_number
# Publish all the parameters needed for the user to connect to the instance.
# It can be anything: URL(s), password(s), or arbitrary parameters.
# Here we'll just echo back the entered name as instance parameter
[publish-connection-parameter]
recipe = slapos.cookbook:publish
name = Hello $${instance-parameter:configuration.name
# Publishing the title from configuration
title = $${instance-parameter:configuration.title}
repetition_number = $${instance-parameter:configuration.repetition_number}
url = $${hello-world:url}
path = $${render-template:rendered}
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
# Softwaretype default would request softwaretype webservice
[switch-softwaretype]
recipe = slapos.cookbook:softwaretype
default = ${instance-default:output}
webservice = ${instance-webservice:output}
......@@ -44,6 +44,18 @@ output = ${buildout:directory}/instance.cfg
#md5sum = 968bea0fc81dc604a874c53648b7d13f
mode = 0644
# Template for default softwaretype
[instance-default]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-default.cfg.in
output = ${buildout:directory}/instance-default.cfg
# Template for hello-world webservice softwaretype
[instance-webservice]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-helloworld.cfg.in
output = ${buildout:directory}/instance-helloworld.cfg
# Dowloading helloweb service script in parts which would be later used in service
[template-download]
recipe = hexagonit.recipe.download
......
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