Jupyter: Switch to using JSON in instance parameters
[slapos.git] / software / ipython_notebook / instance.cfg.in
1 [buildout]
2 parts =
3   instance
4   publish-connection-parameter
5 ## Monitoring part XXX whe should not have to specify all parts like this
6 ## Parts to add for monitoring
7   certificate-authority
8   cron
9   cron-entry-monitor
10   cron-entry-rss
11   deploy-index
12   deploy-settings-cgi
13   deploy-status-cgi
14   deploy-status-history-cgi
15   setup-static-files
16   certificate-authority
17   zero-parameters
18   public-symlink
19   cgi-httpd-wrapper
20   cgi-httpd-graceful-wrapper
21   monitor-promise
22   monitor-instance-log-access
23 ## Monitor for ipython
24   monitor-current-log-access
25   monitor-deploy-set-password-cgi
26   erp5-kernel
27   kernel-json
28   custom-js
29
30 extends = {{ monitor_template }}
31
32 eggs-directory = {{ eggs_directory }}
33 develop-eggs-directory = {{ develop_eggs_directory }}
34 offline = true
35
36 [slapconfiguration]
37 recipe = slapos.cookbook:slapconfiguration.serialised
38 computer = ${slap-connection:computer-id}
39 partition = ${slap-connection:partition-id}
40 url = ${slap-connection:server-url}
41 key = ${slap-connection:key-file}
42 cert = ${slap-connection:cert-file}
43
44 [instance-parameter]
45 port = 8888
46 host = ${slapconfiguration:ipv6-random}
47 cert_file = ${generate-certificate:cert_file}
48 key_file = ${generate-certificate:key_file}
49 logfile = ${directory:log}/ipython_notebook.log
50 notebook_dir = ${directory:notebook_dir}
51
52 [dynamic-jinja2-template-base]
53 recipe = slapos.recipe.template:jinja2
54 mode = 0644
55
56 [generate-certificate]
57 ; TODO: there is a slapos recipe to generate certificates. Use it instead
58 recipe = plone.recipe.command
59 command =
60   if [ ! -e ${instance-parameter:key_file} ]
61   then
62     {{ openssl_output }} req -x509 -nodes -days 3650 \
63       -subj "/C=AA/ST=X/L=X/O=Dis/CN=${instance-parameter:host}" \
64       -newkey rsa:1024 -keyout ${instance-parameter:key_file} \
65       -out ${instance-parameter:cert_file}
66   fi
67 update-command = ${:command}
68 cert_file = ${directory:etc}/ipython_notebook_cert.crt
69 key_file = ${directory:etc}/ipython_notebook_cert.key
70
71 [instance]
72 recipe = slapos.cookbook:wrapper
73 command-line =
74   {{ bin_directory }}/ipython notebook
75   --no-browser
76   --ip=${instance-parameter:host}
77   --port=${instance-parameter:port}
78   --port-retries=0
79   --certfile=${instance-parameter:cert_file}
80   --keyfile=${instance-parameter:key_file}
81   --notebook-dir=${instance-parameter:notebook_dir}
82   --logfile=${instance-parameter:logfile}
83   --config=${ipython-notebook-config:rendered}
84 # Add 'log-level' alias to 'DEBUG' so as to log requests being done while running
85 # of service ipython_notebook.
86   --log-level="DEBUG"
87 wrapper-path = ${directory:service}/ipython_notebook
88 parameters-extra = true
89 # Explicitly define IPython Directory to be used while starting ipython notebook
90 environment = IPYTHONDIR=${directory:ipython_dir}
91
92 [ipython-notebook-config]
93 <= dynamic-jinja2-template-base
94 template = {{ ipython_notebook_config_location }}/{{ ipython_notebook_config_filename }}
95 rendered = ${directory:etc}/ipython_notebook_config.py
96 mode = 0744
97 context =
98   raw config_cfg ${buildout:directory}/knowledge0.cfg
99
100 [monitor-current-log-access]
101 < = monitor-directory-access
102 source = ${instance-parameter:logfile}
103
104 [monitor-deploy-set-password-cgi]
105 <= dynamic-jinja2-template-base
106 template = {{ ipython_notebook_set_password_location }}/{{ ipython_notebook_set_password_filename }}
107 rendered = ${monitor-directory:knowledge0-cgi}/${:filename}
108 filename = ipython-notebook-password.cgi
109 mode = 0744
110 context =
111   raw config_cfg ${buildout:directory}/knowledge0.cfg
112   raw python_executable {{ bin_directory }}/ipython
113   key pwd monitor-directory:knowledge0-cgi
114   key this_file :filename
115   key httpd_graceful cgi-httpd-graceful-wrapper:rendered
116
117 [directory]
118 recipe = slapos.cookbook:mkdirectory
119 home = ${buildout:directory}
120 etc = ${:home}/etc
121 var = ${:home}/var
122 script = ${:etc}/run/
123 service = ${:etc}/service
124 promise = ${:etc}/promise/
125 log = ${:var}/log
126 notebook_dir = ${:var}/notebooks
127 # Add folders to explicitly define ipython directory
128 ipython_dir = ${:home}/ipython
129 ipython_kernel_dir = ${:ipython_dir}/kernels
130 erp5_kernel_dir = ${:ipython_kernel_dir}/ERP5
131
132 [publish-connection-parameter]
133 recipe = slapos.cookbook:publish.serialised
134 url = https://[${instance-parameter:host}]:${instance-parameter:port}
135 monitor_url = ${monitor-parameters:url}
136
137 [erp5-kernel]
138 <= dynamic-jinja2-template-base
139 template = {{ erp5_kernel_location }}/{{ erp5_kernel_filename }}
140 rendered = ${directory:erp5_kernel_dir}/ERP5kernel.py
141 # Use ipython as executable python as we'll be needing requests library in kernel
142 context =
143   raw python_executable {{ bin_directory }}/ipython
144
145 [kernel-json]
146 <= dynamic-jinja2-template-base
147 template = {{ kernel_json_location }}/{{ kernel_json_filename }}
148 rendered = ${directory:erp5_kernel_dir}/kernel.json
149 # Use python2.7 executable bin file for kernel config
150 context =
151   raw python_executable {{ python_executable }}
152   key kernel_dir erp5-kernel:rendered
153   raw display_name ERP5
154   raw language_name python
155
156 [custom-js]
157 <= dynamic-jinja2-template-base
158 template = {{ custom_js_location }}/{{ custom_js_filename }}
159 rendered = ${directory:ipython_dir}/profile_default/static/custom/custom.js
160 mode = 0744