instance-theia.cfg.jinja.in 23 KB
Newer Older
1 2
{% set parameter_dict = dict(default_parameter_dict, **parameter_dict) %}
{% set additional_frontend = parameter_dict['additional-frontend-guid'] %}
3

4 5
[buildout]
extends =
6
  ${monitor-template:output}
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

theia-environment-parts =
  tasks.json
  slapos-repository
  runner-link
  settings.json
  request-script-template

theia-parts =
  frontend-reload
  promises

parts =
  monitor-base
  $${:theia-parts}
  $${:theia-environment-parts}
  publish-connection-parameter

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true


[publish-connection-parameter]
<= monitor-publish
recipe = slapos.cookbook:publish
33 34 35 36
url = $${remote-frontend:connection-secure_access}
{% if additional_frontend %}
additional-url = $${remote-additional-frontend:connection-secure_access}
{% endif %}
37 38 39
username = $${frontend-instance-password:username}
password = $${frontend-instance-password:passwd}
backend-url = $${frontend-instance:url}
40
ipv6 = {{ ipv6_random }}
41 42 43

[directory]
recipe = slapos.cookbook:mkdirectory
44 45 46 47 48 49 50
home = $${buildout:directory}
etc = $${:home}/etc
var = $${:home}/var
srv = $${:home}/srv
bin = $${:home}/bin
tmp = $${:home}/tmp
dot-theia = $${:home}/.theia/
51 52 53 54
pidfiles = $${:var}/run

services = $${:etc}/service
runner = $${:srv}/runner
55
backup = $${:srv}/backup/theia
56
project = $${:srv}/project
57

58 59 60 61
frontend-static = $${:srv}/frontend-static
frontend-static-public = $${:frontend-static}/public
frontend-static-css = $${:frontend-static}/css

62 63
bash-completions = $${:home}/.local/share/bash-completion/completions/
fish-completions = $${:home}/.config/fish/completions/
64 65


66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
# Monitor
# -------

[monitor-instance-parameter]
monitor-httpd-port = {{ parameter_dict['monitor-httpd-port'] }}
{%- for k in ('monitor-cors-domains', 'monitor-username', 'monitor-password') %}
{%-   set v = parameter_dict.get(k) %}
{%-   if v %}
{{ k[8:] }} = {{ v }}
{%-   endif %}
{%- endfor %}
{%- for k in ('monitor-url-list', ) %}
{%-   set v = parameter_dict.get(k) %}
{%-   if v %}
{{ k }} = {{ v }}
{%-   endif %}
{%- endfor %}


85 86 87 88 89 90 91 92
# Promises
# --------

[promises]
recipe =
instance-promises =
  $${theia-listen-promise:name}
  $${frontend-listen-promise:name}
93
  $${frontend-authentication-promise:name}
94 95 96 97
  $${remote-frontend-url-available-promise:name}
  {% if additional_frontend %}
  $${remote-additional-frontend-url-available-promise:name}
  {% endif %}
98
  $${slapos-standalone-listen-promise:name}
99
  $${slapos-standalone-ready-promise:name}
100 101 102 103
  $${slapos-autorun-promise:name}

[theia-listen-promise]
<= monitor-promise-base
104
promise = check_socket_listening
105
name = $${:_buildout_section_name_}.py
106
config-host = $${theia-instance:ip}
107 108 109 110
config-port = $${theia-instance:port}

[frontend-listen-promise]
<= monitor-promise-base
111
promise = check_socket_listening
112
name = $${:_buildout_section_name_}.py
113
config-host = $${frontend-instance:ip}
114 115
config-port = $${frontend-instance:port}

116
[frontend-authentication-promise]
117
<= monitor-promise-base
118
promise = check_url_available
119 120 121
name = $${:_buildout_section_name_}.py
ip = $${frontend-instance:ip}
port = $${frontend-instance:port}
122 123 124
config-url = https://[$${:ip}]:$${:port}
config-username = $${frontend-instance-password:username}
config-password = $${frontend-instance-password:passwd}
125

126
[remote-frontend-url-available-promise]
127
<= monitor-promise-base
128
promise = check_url_available
129
name = $${:_buildout_section_name_}.py
130
config-url = $${remote-frontend:connection-secure_access}
131
config-http-code = 401
132

133 134 135
{% if additional_frontend %}
[remote-additional-frontend-url-available-promise]
<= monitor-promise-base
136
promise = check_url_available
137 138
name = $${:_buildout_section_name_}.py
config-url = $${remote-additional-frontend:connection-secure_access}
139
config-http-code = 401
140 141
{% endif %}

142 143
[slapos-standalone-listen-promise]
<= monitor-promise-base
144
promise = check_socket_listening
145 146
# XXX promise plugins can not contain "slapos" in their names
name = standalone-listen-promise.py
147
config-host = $${slapos-standalone-instance:hostname}
148 149
config-port = $${slapos-standalone-instance:port}

150 151
[slapos-standalone-ready-promise]
<= monitor-promise-base
152
promise = check_socket_listening
153
name = standalone-ready-promise.py
154
config-abstract = $${slapos-standalone-config:abstract-socket-path}
155

156 157
[slapos-autorun-promise]
<= monitor-promise-base
158
promise = check_service_state
159 160 161
name = autorun-state-promise.py
config-service = $${slapos-autorun:service-name}
config-expect = $${slapos-autorun:autorun}
162
config-run-directory = $${directory:runner}/var/run
163 164


165 166
# Remote Caddy Frontend
# ---------------------
167

168
[remote-frontend-base]
169 170 171 172 173 174
<= slap-connection
recipe = slapos.cookbook:requestoptional
slave = true
config-url = $${frontend-instance:url}
config-https-only = true
config-type = websocket
175
config-websocket-path-list = /services /socket.io
176 177
return = domain secure_access

178 179
[remote-frontend]
<= remote-frontend-base
180 181 182
name = {{ parameter_dict['frontend-name'] }}
software-url = {{ parameter_dict['frontend-sr'] }}
software-type = {{ parameter_dict['frontend-sr-type'] }}
183
{%- if parameter_dict.get('frontend-guid') %}
184
sla-instance_guid = {{ parameter_dict['frontend-guid'] }}
185
{%- endif %}
186 187 188 189

{% if additional_frontend %}
[remote-additional-frontend]
<= remote-frontend-base
190 191 192
name = {{ parameter_dict['additional-frontend-name'] }}
software-url = {{ parameter_dict['additional-frontend-sr'] }}
software-type = {{ parameter_dict['additional-frontend-sr-type'] }}
193
{%- if parameter_dict.get('additional-frontend-guid') %}
194
sla-instance_guid = {{ parameter_dict['additional-frontend-guid'] }}
195
{%- endif %}
196 197
{% endif %}

198 199 200 201 202 203 204

# Local Caddy Frontend
# --------------------

[frontend-instance-password]
recipe = slapos.cookbook:generate.password
username = admin
205
storage-path = $${buildout:parts-directory}/.$${:_buildout_section_name_}
206 207 208 209 210

[frontend-instance-port]
recipe = slapos.cookbook:free_port
minimum = 3000
maximum = 3100
211
ip = {{ ipv6_random }}
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231

[frontend-instance-certificate]
recipe = plone.recipe.command
command =
  if [ ! -e $${:key-file} ]
  then
    ${openssl-output:openssl} req -x509 -nodes -days 3650 \
      -subj "/C=AA/ST=X/L=X/O=Dis/CN=$${:common-name}" \
      -newkey rsa:1024 -keyout $${:key-file} \
      -out $${:cert-file}
  fi
update-command = $${:command}
key-file = $${directory:etc}/$${:_buildout_section_name_}.key
cert-file = $${directory:etc}/$${:_buildout_section_name_}.crt
common-name = $${frontend-instance-config:ip}
location =
  $${:key-file}
  $${:cert-file}

[frontend-instance-config]
232 233 234
recipe = slapos.recipe.template
output = $${directory:etc}/$${:_buildout_section_name_}
inline =
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
  :$${:port} {
    bind $${:ip}
    tls $${frontend-instance-certificate:cert-file} $${frontend-instance-certificate:key-file}
    log stdout
    errors stderr
    gzip
    # because caddy does not support upgrade http2 to websocket
    # https://tools.ietf.org/html/rfc8441
    tls {
      alpn http/1.1
    }
    root $${directory:frontend-static}
    browse
    proxy / $${theia-instance:base-url} {
      except $${frontend-instance-fonts:folder-name} $${frontend-instance-slapos.css:folder-name} public $${favicon.ico:filename} $${frontend-instance-logo:filename}
    }
    proxy /services $${theia-instance:base-url} {
      websocket
    }
254 255 256
    proxy /socket.io $${theia-instance:base-url} {
      websocket
    }
257 258 259 260 261 262 263 264 265 266 267 268 269
    basicauth $${frontend-instance-password:username} $${frontend-instance-password:passwd} {
      realm "Theia"
      /
    }
  }
ip = $${frontend-instance-port:ip}
hostname = [$${:ip}]
port = $${frontend-instance-port:port}

[frontend-instance]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line =
270
  ${caddy:output} -conf $${frontend-instance-config:output} -pidfile $${:pidfile}
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299

ip = $${frontend-instance-config:ip}
hostname = $${frontend-instance-config:hostname}
port = $${frontend-instance-config:port}
pidfile = $${directory:pidfiles}/$${:_buildout_section_name_}.pid
url = https://$${:hostname}:$${:port}/

[frontend-instance-fonts]
; XXX caddy 1 does not seem to serve different folders at different locations
; so we link fonts in static folder
recipe = plone.recipe.command
location = $${directory:frontend-static}/$${:folder-name}
folder-name = fonts
command =
  mkdir -p $${:location}
  ln -sf ${source-code-pro-fonts:location} $${:location}/source-code-pro
  ln -sf ${jetbrains-mono-fonts:location} $${:location}/jetbrains-mono
stop-on-error = true

[frontend-instance-logo]
recipe = plone.recipe.command
filename = logo.png
full-path = $${directory:frontend-static}/$${:filename}
command =
  cp --remove-destination ${logo.png:output} $${:full-path}
stop-on-error = true

[frontend-instance-slapos.css]
recipe = slapos.recipe.template:jinja2
300 301
url = ${slapos.css.in:output}
output = $${directory:frontend-static}/$${:folder-name}/slapos.css
302 303 304 305 306 307 308 309 310 311 312 313
folder-name = css
context =
  key logo_image frontend-instance-logo:filename

[frontend-reload]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line =
  ${bash:location}/bin/bash -c
  "kill -s USR1 $$(${coreutils:location}/bin/cat $${frontend-instance:pidfile}) \
    && ${coreutils:location}/bin/sleep infinity"
hash-files =
314
  $${frontend-instance-config:output}
315 316 317 318 319 320
  $${frontend-instance:wrapper-path}
wait-for-files = $${frontend-instance:pidfile}

[favicon.ico]
# generate a pseudo random favicon, different for each instance name.
recipe = slapos.recipe.build
321
seed = {{ root_title }}
322 323 324 325 326 327
install =
  import hashlib, shutil
  buildout_offline = self.buildout['buildout']['offline']
  self.buildout['buildout']['offline'] = 'false'
  try:
    gravatar_url = "https://www.gravatar.com/avatar/" + hashlib.md5(
328
      b'''$${:seed}'''
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
    ).hexdigest() + "?s=256&d=retro"
    shutil.copy(self.download(gravatar_url), '''$${:location}''')
  except Exception:
    # Because installation should work offline, if we can't download a favicon,
    # just ignore this step.
    self.logger.exception("Error while downloading favicon, using empty one")
    open('''$${:location}''', 'w').close()
  finally:
    self.buildout['buildout']['offline'] = buildout_offline

location = $${directory:frontend-static}/$${:filename}
filename = $${:_buildout_section_name_}


# Common Environment
# ------------------

[common-environment]
347 348 349
recipe = slapos.recipe.template
output = $${directory:bin}/$${:_buildout_section_name_}
inline =
350
  #!/bin/sh
351
  export HOME=$${directory:home}
352
  export PATH=${python-language-server:location}/bin:${java-jdk:location}/bin:${cli-utilities:PATH}:$HOME/.cargo/bin:$PATH
353
  export IPV6_SLAPRUNNER={{ ipv6_random }}
354 355 356 357 358 359 360 361

# Theia Backend
# -------------

[theia-service-port]
recipe = slapos.cookbook:free_port
minimum = 3500
maximum = 3600
362
ip = {{ ipv4_random }}
363 364

[theia-service]
365 366 367 368
recipe = slapos.recipe.template
output = $${directory:bin}/$${:_buildout_section_name_}
inline =
  #!/bin/sh
369 370 371
  {{ "{% raw %}" }}
  {% raw %}
  export THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{hostname}}'
372
  export THEIA_MINI_BROWSER_HOST_PATTERN='{{hostname}}'
373 374 375 376
  {% endraw %}
  {{ "{% endraw %}" }}
  export THEIA_OPEN_EDITOR_TOKEN=$(${openssl:location}/bin/openssl rand -hex 32)
  export THEIA_URL=$${:base-url}
377
  export THEIA_SHELL=$${theia-shell:output}
378 379 380 381
  export TMP=$${directory:tmp}
  export TEMP=$TMP
  export LC_ALL=C.UTF-8
  export TERMINFO=${ncurses:location}/lib/terminfo/
382
  export EDITOR="${theia-open:output} --wait"
383
  export THEIA_DEFAULT_PLUGINS="local-dir:${theia-plugins:location}"
384 385
  . $${common-environment:output}
  exec ${theia-wrapper:output} "$@"
386 387 388 389 390 391 392
ip =  $${theia-service-port:ip}
port = $${theia-service-port:port}
base-url = http://$${:ip}:$${:port}/

[theia-instance]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
393
command-line = $${theia-service:output}  --hostname=$${:hostname} --port=$${:port} $${directory:project}
394
hash-existing-files =
395
  ${yarn.lock:target}
396
  ${theia-wrapper:output}
397
ip =  {{ ipv4_random }}
398 399 400 401 402 403
hostname = $${:ip}
port = $${theia-service:port}
base-url = $${theia-service:base-url}

[theia-shell]
recipe = slapos.recipe.template:jinja2
404 405
output = $${directory:bin}/$${:_buildout_section_name_}
inline ={% raw %}#!{{ bash }}
406 407 408 409 410 411 412 413 414 415 416
  SHELL=$BASH
  # when running interactively, activate slapos configuration and reset GIT_EXEC_PATH to workaround https://github.com/eclipse-theia/theia/issues/7555
  if [ $# = 0 ]; then
    . {{ activate }}
    unset GIT_EXEC_PATH
    set -- --rcfile {{ bashrc }}
  fi
  exec "$SHELL" "$@"
  {% endraw %}
context =
  raw bash ${bash:location}/bin/bash
417 418
  key activate slapos-standalone-activate:output
  key bashrc theia-bashrc:output
419 420

[theia-bashrc]
421 422 423
recipe = slapos.recipe.template
output = $${directory:etc}/$${:_buildout_section_name_}
inline =
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
  # enable bash completion
  . ${bash-completion:location}/etc/profile.d/bash_completion.sh
  # source user's .bashrc
  [ -f ~/.bashrc ] && . ~/.bashrc
depends =
  $${shell-setup-completion:recipe}

[shell-setup-completion]
recipe = plone.recipe.command
stop-on-error = true
command =
  ${buildout:bin-directory}/slapos complete > $${directory:bash-completions}/slapos
  ${buildout:bin-directory}/slapos complete --shell fish > $${directory:fish-completions}/slapos.fish


439 440 441 442 443 444 445 446 447 448 449 450
# Embedded Instance
# -----------------

{%- set embedded_sr = parameter_dict['embedded-sr'] %}
{%- set embedded_sr_type = parameter_dict['embedded-sr-type'] %}
{%- set embedded_instance_parameters = parameter_dict['embedded-instance-parameters'] %}
{%- if embedded_sr %}
{%-   if embedded_sr.startswith('~/') %}
{%-     set embedded_sr = os_module.path.join(partition_root_path, embedded_sr[2:]) %}
{%-     set embedded_sr = os_module.path.normpath(embedded_sr) %}
{%-   endif %}
[request-embedded-instance-script]
451 452 453 454
recipe = slapos.recipe.template
output = $${directory:project}/request_embedded.sh
inline =
  #!/bin/sh
455 456 457

  slapos supply {{ embedded_sr }} slaprunner

458
  slapos request "embedded_instance" {{ embedded_sr }}
459
{%-   if embedded_sr_type %} --type {{ embedded_sr_type }} {%- endif %}
460
{%-   if embedded_instance_parameters %} --parameters-file $${embedded-instance-parameters:output}
461 462

[embedded-instance-parameters]
463 464 465
recipe = slapos.recipe.template
output = $${directory:project}/$${:_buildout_section_name_}.json
inline ={{ embedded_instance_parameters | indent(2) }}
466 467 468
{%-   endif %}
{%- endif %}

469 470 471
{%- set embedded_digest = str(embedded_sr) + str(embedded_sr_type) + str(embedded_instance_parameters) %}
{%- set embedded_digest_hash = hashlib_module.md5(embedded_digest.encode()).hexdigest() %}

472

473 474 475 476 477 478 479
# SlapOS Standalone
# -----------------

[slapos-standalone-port]
recipe = slapos.cookbook:free_port
minimum = 4000
maximum = 4100
480
ip = {{ ipv4_random }}
481 482

[slapos-standalone-config]
483 484
ipv4 = {{ ipv4_random }}
ipv6 = {{ ipv6_random }}
485
port = $${slapos-standalone-port:port}
486
local-software-release-root = $${directory:home}
487 488
slapos-configuration = $${directory:runner}/etc/slapos.cfg
computer-id = slaprunner
489
abstract-socket-path = $${directory:home}/standalone-{{ embedded_digest_hash[:16] }}
490 491

[slapos-standalone-activate]
492 493 494
recipe = slapos.recipe.template
output = $${directory:bin}/$${:_buildout_section_name_}
inline =
495 496 497 498 499
  export PATH=${buildout:bin-directory}:$PATH
  export SLAPOS_CONFIGURATION=$${slapos-standalone-config:slapos-configuration}
  export SLAPOS_CLIENT_CONFIGURATION=$SLAPOS_CONFIGURATION
  echo 'Standalone SlapOS for computer `$${slapos-standalone-config:computer-id}` activated'

500
[slapos-standalone-script]
501 502 503 504
recipe = slapos.recipe.template
output = $${directory:bin}/$${:_buildout_section_name_}
inline =
  #!${python-for-standalone:executable}
505 506 507 508 509 510 511 512 513 514 515 516
  import glob
  import json
  import os
  import signal
  import socket
  import subprocess
  import sys
  import time
  import traceback

  import slapos.slap.standalone

517 518 519
  # Include this hash, so that if it changes the standalone service will be restarted
  # {{ embedded_digest_hash }}

520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
  shared_parts = """{{ '''${buildout:shared-part-list}''' | indent(2) }}"""
  shared_part_list = [x.strip() for x in shared_parts.splitlines() if x.strip()]
  partition_forward_configuration = (
    slapos.slap.standalone.PartitionForwardAsPartitionConfiguration(
      master_url="$${slap-connection:server-url}",
      computer="$${slap-connection:computer-id}",
      partition="$${slap-connection:partition-id}",
      cert="$${slap-connection:cert-file}",
      key="$${slap-connection:key-file}",
      software_release_list=(
        'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg',
      ),
    ),
  )
  standalone = slapos.slap.standalone.StandaloneSlapOS(
    "$${directory:runner}",
    "$${slapos-standalone-config:ipv4}",
    $${slapos-standalone-config:port},
    computer_id="$${slapos-standalone-config:computer-id}",
    shared_part_list=shared_part_list,
    software_root="$${directory:runner}/software",
    instance_root="$${directory:runner}/instance",
    partition_forward_configuration=partition_forward_configuration,
    slapos_bin="${buildout:bin-directory}/slapos",
    local_software_release_root="$${slapos-standalone-config:local-software-release-root}",
  )

  def signal_handler(signum, frame):
    print("Signal {signum} received".format(signum=signum))
    sys.exit()
  signal.signal(signal.SIGTERM, signal_handler)

  standalone.start()
  try:
    partition_count = 20
    print("Standalone SlapOS: Formatting %d partitions" % partition_count)
    standalone.format(partition_count, '$${slapos-standalone-config:ipv4}', '$${slapos-standalone-config:ipv6}')
    print("Standalone SlapOS for computer `$${slapos-standalone-config:computer-id}` started")
    # Run instance at least once, to start the supervisor managing instances.
    try:
      standalone.waitForInstance(max_retry=0)
    except slapos.slap.standalone.SlapOSNodeCommandError as e:
      print("Error instanciating: {}".format(e))
{%- if embedded_sr %}
    # Compatibility layer
    try:
      for cp in standalone.computer.getComputerPartitionList():
        if cp.getInstanceParameterDict().get("instance_title") == "Embedded Instance":
          print("Renaming 'Embedded Instance' into 'embedded_instance'")
          cp.rename(new_name="embedded_instance")
          break
    except Exception:
      print("Exception in compatibility layer, printing and moving on")
      traceback.print_exc()
    # Run request script
575
    print("Running SlapOS script $${request-embedded-instance-script:output}")
576 577 578 579 580
    slapos_env = {
      'PATH': os.path.dirname(standalone._slapos_bin),
      'SLAPOS_CONFIGURATION': standalone._slapos_config,
      'SLAPOS_CLIENT_CONFIGURATION': standalone._slapos_config
    }
581
    subprocess.call(("$${request-embedded-instance-script:output}",), env=slapos_env)
582 583 584 585 586 587 588 589 590 591 592 593
{%- endif %}
    s = socket.socket(socket.AF_UNIX)
    s.bind("\0$${slapos-standalone-config:abstract-socket-path}")
    s.listen(5)
    print("Standalone SlapOS ready")
    while True:
      s.accept()[0].close()
  finally:
    print("Stopping standalone subsystem")
    standalone.stop()
    print("Exiting")

594
[slapos-standalone]
595 596 597 598 599
recipe = slapos.recipe.template
output = $${directory:bin}/$${:_buildout_section_name_}
inline =
  #!/bin/sh
  . $${common-environment:output}
600 601
  #XXX find out where the extra nodejs in theia's PATH comes from
  export PATH=${nodejs:location}/bin/:$PATH
602 603
  . $${slapos-standalone-activate:output}
  exec $${slapos-standalone-script:output}
604 605 606 607

[slapos-standalone-instance]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
608
command-line = $${slapos-standalone:output}
609
hash-files =
610 611
  $${slapos-standalone:output}
  $${slapos-standalone-script:output}
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
hostname = $${slapos-standalone-config:ipv4}
port = $${slapos-standalone-config:port}


# Slapos Standalone Autoprocessing
# --------------------------------

[slapos-autorun]
recipe = plone.recipe.command
command =
  case $${:autorun} in
    ( running ) ${buildout:bin-directory}/supervisorctl -c $${:supervisor-conf} start $${:service-name};;
    ( stopped ) ${buildout:bin-directory}/supervisorctl -c $${:supervisor-conf} stop $${:service-name};;
  esac
update-command = $${:command}
service-name = slapos-node-auto
supervisor-conf = $${directory:runner}/etc/supervisord.conf
629
autorun = {{ parameter_dict['autorun'] }}
630 631 632 633 634 635


# Theia Local Environment Setup
# -----------------------------

[tasks.json]
636 637 638
recipe = slapos.recipe.template
output = $${directory:dot-theia}/tasks.json
inline =
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
  {
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
      {
        "label": "slapos node software",
        "detail": "Build all software supplied to the node",
        "type": "shell",
        "command": "${buildout:bin-directory}/slapos",
        "args": [
          "node",
          "software",
          // debug mode can be enabled by commenting out this line:
          // "--buildout-debug",
          "--all"
        ],
        "options": {
          "env": {
            "SLAPOS_CONFIGURATION": "$${slapos-standalone-config:slapos-configuration}",
            "GIT_EXEC_PATH": ""
          }
        },
        "group": {
          "kind": "build",
          "isDefault": true
        },
        "problemMatcher": []
      },
      {
        "label": "slapos node instance",
        "detail": "Create all instances requested on the node",
        "type": "shell",
        "command": "${buildout:bin-directory}/slapos",
        "args": [
          "node",
          "instance",
          // debug mode can be enabled by commenting out this line:
          // "--buildout-debug",
          "--all"
        ],
        "options": {
          "env": {
            "SLAPOS_CONFIGURATION": "$${slapos-standalone-config:slapos-configuration}",
            "GIT_EXEC_PATH": ""
          }
        },
        "problemMatcher": [],
        "group": {
          "kind": "build",
          "isDefault": true
        }
      }
    ]
  }

[slapos-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/nexedi/slapos.git
location = $${directory:project}/slapos
branch = 1.0
develop = true
git-executable = ${git:location}/bin/git

[settings.json]
recipe = slapos.recipe.template:jinja2
705 706 707
output = $${directory:dot-theia}$${:_buildout_section_name_}
once = $${:output}
inline =
708 709 710 711 712 713 714 715
  {
    "files.watcherExclude": {
      "**/.eggs/**": true,
      "**/.env/**": true,
      "**/.git/**": true,
      "**/node_modules/**": true,
      "$${directory:runner}/**":true,
      "$${directory:project}/runner/**":true
716
    },
717 718
    "git.terminalAuthentication": false,
    "security.workspace.trust.startupPrompt": "once"
719 720 721 722 723 724 725 726
  }

[runner-link]
recipe = slapos.cookbook:symbolic.link
target-directory = $${directory:project}
link-binary = $${directory:runner}

[request-script-template]
727 728 729 730
recipe = slapos.recipe.template
output = $${directory:project}/$${:_buildout_section_name_}.sh
inline =
  #!/bin/sh
731 732 733 734 735 736 737 738 739 740
  # This template is generated automatically, copy it in order to supply and request.
  # Any manual change to this file may be lost.
  software_name=html5as-base #replace the software name writen in ~/srv/project/slapos/software/
  software_release_uri=~/srv/project/slapos/software/$software_name/software.cfg
  # slapos supply is used to add the software to the software list to be supplied to a node.
  slapos supply $software_release_uri slaprunner
  # slapos request the allocation of an instance to the master.
  # slapos request also gets status and parameters of the instance if it has any
  # (slapos request is meant to be run multiple time until you get the status).
  slapos request $software_name'_1' $software_release_uri