Commit 75b9189f authored by Alain Takoudjou's avatar Alain Takoudjou

headless-chromium: fix software release and add more options

parent bfd5cb9f
...@@ -26,5 +26,8 @@ The following instance parameters can be configured: ...@@ -26,5 +26,8 @@ The following instance parameters can be configured:
- remote-debugging-port: Port for Chromium to listen on. - remote-debugging-port: Port for Chromium to listen on.
- nginx-proxy-port: Port for Ningx proxy to listen on. - nginx-proxy-port: Port for Ningx proxy to listen on.
- monitor-httpd-port: Port for monitor. - monitor-httpd-port: Port for monitor.
- incognito: Force Incognito mode
- window-size: Initial windo size
- block-new-web-contents: Block new web contents
See `instance-headless-chromium-input-schema.json` for default values. See `instance-headless-chromium-input-schema.json` for default values.
[template-cfg] [template-cfg]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 4d73fe3c5d286163974bdb79c838e030 md5sum = 6315598b2c7c19f9e2d9cdf090492e2c
[instance-headless-chromium] [instance-headless-chromium]
_update_hash_filename_ = instance-headless-chromium.cfg.in _update_hash_filename_ = instance-headless-chromium.cfg.in
md5sum = d72e5f6e159081f1c204ceb7ec0c0caf md5sum = a350b7b5ac03971f1b8d66949905c164
[template-nginx-conf] [template-nginx-conf]
_update_hash_filename_ = templates/nginx.conf.in _update_hash_filename_ = templates/nginx.conf.in
md5sum = c4d09d2b819f624087ef4c38551dfe2f md5sum = 1f35f91fa7e490cd1e2194264a8a6ed8
[template-mime-types] [template-mime-types]
_update_hash_filename_ = templates/mime-types.in _update_hash_filename_ = templates/mime-types.in
......
{ {
"type": "object", "type": "object",
"$schema": "http://json-schema.org/draft-04/schema", "$schema": "http://json-schema.org/draft-04/schema",
"required": [
"target-url"
],
"title": "Input Parameters", "title": "Input Parameters",
"properties": { "properties": {
"target-url": { "target-url": {
"description": "URL for Chromium to load on startup.", "description": "Web site URL to load on headless chromium.",
"title": "Target URL", "title": "Application target URL",
"type": "string", "type": "string"
"default": "https://www.example.com"
}, },
"remote-debugging-port": { "remote-debugging-port": {
"description": "Port for Chromium to listen on.", "description": "Port for Chromium to listen on.",
"title": "Remote Debugging Port", "title": "Remote Debugging Port",
"type": "integer", "type": "integer",
"default": 8081 "default": 9222
}, },
"nginx-proxy-port": { "nginx-proxy-port": {
"description": "Port for Nginx proxy to listen on.", "description": "Port for Nginx proxy to listen on.",
"title": "Nginx Proxy Port", "title": "Nginx Proxy Port",
"type": "integer", "type": "integer",
"default": 8082 "default": 9224
},
"incognito": {
"description": "Force Incognito mode",
"title": "Force Incognito mode",
"type": "boolean",
"default": true
},
"window-size": {
"description": "Set the initial window size. Provided as string in the format \"800,600\".",
"title": "Initial windo size",
"type": "string",
"default": "800,600"
},
"block-new-web-contents": {
"description": "If true, then all pop-ups and calls to window.open will fail.",
"title": "Block new web contents",
"type": "boolean",
"default": false
}, },
"monitor-httpd-port": { "monitor-httpd-port": {
"description": "Port for monitor frontend.", "description": "Port for monitor frontend.",
......
{% set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %} {% set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %}
[buildout]
parts =
chromium-launcher
generate-passwd-file
nginx-config
nginx-mime-types
nginx-launcher
logrotate-entry-nginx
publish-connection-information
frontend-ok-promise
frontend-secure-promise
eggs-directory = {{ buildout['eggs-directory'] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }}
offline = true
extends = {{ parameter_list['template-monitor'] }}
# Create necessary directories. # Create necessary directories.
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
...@@ -34,7 +16,10 @@ service = ${:etc}/service ...@@ -34,7 +16,10 @@ service = ${:etc}/service
ipv4 = {{ partition_ipv4 }} ipv4 = {{ partition_ipv4 }}
ipv6 = {{ partition_ipv6 }} ipv6 = {{ partition_ipv6 }}
remote-debugging-port = {{ parameter_dict['remote-debugging-port'] }} remote-debugging-port = {{ parameter_dict['remote-debugging-port'] }}
url = {{ parameter_dict['target-url'] }} target-url = {{ parameter_dict['target-url'] }}
incognito = {{ parameter_dict['incognito'] }}
window-size = {{ parameter_dict['window-size'] }}
block-new-web-contents = {{ parameter_dict['block-new-web-contents'] }}
remote-debugging-address = ${:ipv4}:${:remote-debugging-port} remote-debugging-address = ${:ipv4}:${:remote-debugging-port}
devtools-frontend-root = {{ parameter_list['devtools-frontend'] }} devtools-frontend-root = {{ parameter_list['devtools-frontend'] }}
...@@ -51,19 +36,29 @@ nginx-cert-file = ${frontend-instance-certificate:cert-file} ...@@ -51,19 +36,29 @@ nginx-cert-file = ${frontend-instance-certificate:cert-file}
nginx-mime-types = ${directory:etc}/mime-types nginx-mime-types = ${directory:etc}/mime-types
# Create a launcher script in /etc/service for the headless shell # Create a wrapper script in /bin/chromium for the headless shell
# executable. # executable.
[chromium-launcher] [chromium-wrapper]
recipe = slapos.recipe.template recipe = slapos.cookbook:wrapper
inline = wrapper-path = ${directory:bin}/chromium
#!/bin/sh command-line =
{{ parameter_list['chromium-wrapper'] }}
--remote-debugging-address=${headless-chromium:ipv4}
--remote-debugging-port=${headless-chromium:remote-debugging-port}
--user-data-dir=${directory:tmp}
--window-size="${headless-chromium:window-size}"
{% if parameter_dict['incognito'] %}--incognito{% endif -%}
{% if parameter_dict['block-new-web-contents'] %}--block-new-web-contents{% endif -%}
{{ '\n "${headless-chromium:target-url}"' }}
environment =
FONTCONFIG_FILE=${font-config:output}
export FONTCONFIG_FILE=${font-config:output} [chromium-launcher]
exec {{ parameter_list['chromium-wrapper'] }} \ recipe = slapos.cookbook:wrapper
--remote-debugging-address=${headless-chromium:ipv4} \ command-line = ${chromium-wrapper:wrapper-path}
--remote-debugging-port=${headless-chromium:remote-debugging-port} \ wrapper-path = ${directory:service}/chromium
${headless-chromium:url} hash-existing-files = ${buildout:directory}/software_release/buildout.cfg
output = ${directory:service}/chromium hash-files = ${chromium-wrapper:wrapper-path}
# Configure and launch the proxy server. # Configure and launch the proxy server.
...@@ -81,7 +76,9 @@ output = ${headless-chromium:nginx-mime-types} ...@@ -81,7 +76,9 @@ output = ${headless-chromium:nginx-mime-types}
[nginx-launcher] [nginx-launcher]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = {{ parameter_list['nginx-location'] }}/sbin/nginx -c ${headless-chromium:nginx-config-target} command-line =
{{ parameter_list['nginx-location'] }}/sbin/nginx
-c ${headless-chromium:nginx-config-target}
wrapper-path = ${directory:service}/nginx wrapper-path = ${directory:service}/nginx
[logrotate-entry-nginx] [logrotate-entry-nginx]
...@@ -189,3 +186,22 @@ name = headless-chromium-frontend-secure.py ...@@ -189,3 +186,22 @@ name = headless-chromium-frontend-secure.py
url = ${remote-debugging-frontend:connection-secure_access} url = ${remote-debugging-frontend:connection-secure_access}
config-url = ${:url} config-url = ${:url}
config-http-code = 401 config-http-code = 401
[buildout]
extends = {{ parameter_list['template-monitor'] }}
parts =
chromium-launcher
generate-passwd-file
nginx-config
nginx-mime-types
nginx-launcher
logrotate-entry-nginx
remote-debugging-frontend
publish-connection-information
frontend-ok-promise
frontend-secure-promise
eggs-directory = {{ buildout['eggs-directory'] }}
develop-eggs-directory = {{ buildout['develop-eggs-directory'] }}
offline = true
...@@ -32,8 +32,11 @@ context = ...@@ -32,8 +32,11 @@ context =
jsonkey default_parameter_dict :default-parameters jsonkey default_parameter_dict :default-parameters
default-parameters = default-parameters =
{ {
"remote-debugging-port": 8081, "remote-debugging-port": 9222,
"nginx-proxy-port": 8082, "nginx-proxy-port": 9224,
"incognito": true,
"window-size": "800,600",
"block-new-web-contents": false,
"target-url": "https://www.example.com", "target-url": "https://www.example.com",
"monitor-httpd-port": 8083 "monitor-httpd-port": 8083
} }
......
pid {{ param_headless_chromium['nginx-pid-path'] }}; pid {{ param_headless_chromium['nginx-pid-path'] }};
error_log {{ param_headless_chromium['nginx-error-log'] }}; error_log {{ param_headless_chromium['nginx-error-log'] }};
daemon off;
events { events {
worker_connections 1024; worker_connections 1024;
} }
...@@ -11,12 +13,6 @@ http { ...@@ -11,12 +13,6 @@ http {
include {{ param_headless_chromium['nginx-mime-types'] }}; include {{ param_headless_chromium['nginx-mime-types'] }};
default_type application/octet-stream; default_type application/octet-stream;
types {
text/html html;
text/css css;
application/javascript js;
}
server { server {
listen {{ param_headless_chromium['proxy-address'] }} ssl; listen {{ param_headless_chromium['proxy-address'] }} ssl;
......
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