instance.cfg.in 4.15 KB
Newer Older
1 2 3 4 5 6 7 8 9
#############################
#
# Deploy hello-world instance
#
#############################
[buildout]
parts =
  directory
  hello-world
10
  hello-world-promise
11 12 13 14 15 16 17 18 19 20 21
  publish-connection-parameter

# Define egg directories to be the one from Software Release
# (/opt/slapgrid/...)
# Always the same.
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true


[instance-parameter]
22 23 24 25 26 27
# 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.
28
# See docstring of slapos.cookbook:slapconfiguration for more information.
29 30 31 32 33 34 35 36
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
37
# specify it.
38
# All possible parameters should have a default.
39 40 41 42 43
# 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).
44 45 46 47 48


# Create all needed directories, depending on your needs
[directory]
recipe = slapos.cookbook:mkdirectory
49 50 51
home = $${buildout:directory}
etc = $${:home}/etc
var = $${:home}/var
52 53 54 55 56 57 58
# 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/
59 60
# Path of the log directory used by our service (see [hello-world])
log = $${:var}/log
61 62
# Path of IPython directory in which ERP5 kernel will be running
ipython-directory = $${:home}/.ipython/kernels
63

64 65

# Create a simple web server that says "hello <configuration.name>" to the web.
66
[hello-world]
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
# 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 = 7777
# 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:
83 84
# This recipe will try to "exec" the command-line after separating parameters.
recipe = slapos.cookbook:wrapper
85 86 87
command-line =
    ${hello-web-bin:rendered} --logfile $${hello-world:logfile}
        $${:ipv6} $${:port} $${instance-parameter:configuration.name}
88 89 90
# 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.
91 92 93
wrapper-path = $${directory:service}/hello-world


94 95 96 97 98 99 100 101
# 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}


102 103 104 105 106
# 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
107
name = Hello $${instance-parameter:configuration.name}!
108
url = $${hello-world:url}