Commit 96d96922 authored by Boxiang Sun's avatar Boxiang Sun

peertube: use double template

parent 929143e3
Pipeline #24835 passed with stage
in 0 seconds
...@@ -17,12 +17,12 @@ filename = instance.cfg.in ...@@ -17,12 +17,12 @@ filename = instance.cfg.in
# md5sum = a1f5431f98c2401282064d40bf809eed # md5sum = a1f5431f98c2401282064d40bf809eed
[instance-peertube] [instance-peertube]
filename = instance-peertube.cfg.in _update_hash_filename_ = instance-peertube.cfg.in
# md5sum = 458870b70c33a1621b68961ae2372ad5 # md5sum = edac55a3dd6b666a1134a2f4d9bd5cfd
[template-nginx-service] [template-nginx-service]
filename = template-nginx-service.sh.in filename = template-nginx-service.sh.in
md5sum = 458870b70c33a1621b68961ae2372ad5 # md5sum = 458870b70c33a1621b68961ae2372ad5
[template-peertube-service] [template-peertube-service]
filename = template-peertube-service.sh.in filename = template-peertube-service.sh.in
......
[buildout] [buildout]
extends = extends =
${monitor-template:output} {{ monitor_template }}
parts = parts =
service-redis
promise-redis
postgresql
postgresql-binary-link
nginx-service
nginx-listen-promise
peertube-yaml peertube-yaml
peertube-service peertube-service
peertube-listen-promise peertube-listen-promise
peertube-parameters dcron-service
activate-crontab-file
peertube-backup-cron
peertube-database-resiliency-after-import-script
peertube-database-resiliency-exclude-file
publish-connection-parameter publish-connection-parameter
eggs-directory = ${buildout:eggs-directory} eggs-directory = {{ eggs_directory }}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = {{ develop_eggs_directory }}
offline = true offline = true
[directory]
recipe = slapos.cookbook:mkdirectory
etc = ${buildout:directory}/etc
srv = ${buildout:directory}/srv
var = ${buildout:directory}/var
log = ${:var}/log
run = ${:var}/run
www = ${:var}/www
crontabs = ${:etc}/crontabs
cron-entries = ${:etc}/cron.d
cronstamps = ${:etc}/cronstamps
cron-lines = ${:etc}/cron.lines
nginx = ${:etc}/nginx
peertube_nginx_log = ${:log}/nginx
varnginx = ${:var}/nginx
services = ${:etc}/service
peertube_directory = ${:www}/peertube
config = ${:peertube_directory}/config
storage = ${:peertube_directory}/storage
versions = ${:peertube_directory}/versions
ssl = ${:etc}/ssl
##################
# Postgresql #
##################
[postgresql-password]
recipe = slapos.cookbook:generate.password
[postgresql]
recipe = slapos.cookbook:postgres
bin = {{ postgresql10_location }}/bin/
services = ${directory:services}
dbname = peertube_prod
superuser = peertube
password = ${postgresql-password:passwd}
pgdata-directory = ${directory:srv}/postgresql
ipv44 = {{ slapparameter_dict.get('ipv4-random') }}
ipv4 = {{ ipv4_random }}
# disable listening on ipv6
ipv6 =
port = 5432
[postgresql-binary-link]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:bin}
link-binary = ${postgresql:bin}/postgres ${postgresql:bin}/psql
#############
# Nginx #
#############
[nginx-service]
recipe = slapos.recipe.template
url = {{ tempalte_nginx_service }}
output = ${directory:services}/nginx
virtual-depends =
${nginx-configuration:ip}
[nginx-listen-promise]
<= monitor-promise-base
promise = check_url_available
name = nginx_listen.py
config-verify = 0
config-url = https://[${nginx-configuration:ip}]:${nginx-configuration:port}
[nginx-configuration]
recipe = slapos.recipe.template
url = {{ template_nginx_configration }}
output = ${directory:etc}/nginx.cfg
access_log = ${directory:log}/nginx-access.log
error_log = ${directory:log}/nginx-error.log
ipv6 = {{ slapparameter_dict.get('ipv6-random') }}
ip = {{ ipv6_random }}
port = 9443
ssl_key = ${directory:ssl}/nginx.key
ssl_csr = ${directory:ssl}/nginx.csr
ssl_crt = ${directory:ssl}/nginx.crt
#############
# Redis #
#############
[redis]
recipe = slapos.cookbook:mkdirectory
srv = ${directory:srv}/redis
log = ${directory:log}/redis
[service-redis]
recipe = slapos.cookbook:redis.server
wrapper = ${directory:services}/redis
promise-wrapper = ${directory:bin}/redis-promise
server-dir = ${redis:srv}
config-file = ${directory:etc}/redis.conf
log-file = ${redis:log}/redis.log
pid-file = ${directory:run}/redis.pid
use-passwd = false
unixsocket = ${:server-dir}/redis.socket
# port = 0 means "don't listen on TCP at all" - listen only on unix socket
ipv6 = ::1
port = 0
server-bin = {{ redis_binprefix }}/redis-server
cli-bin = {{ redis_binprefix }}/redis-cli
depend =
${logrotate-entry-redis:recipe}
[promise-redis]
<= monitor-promise-base
promise = check_command_execute
name = promise-redis.py
config-command = ${service-redis:promise-wrapper}
[logrotate-entry-redis]
<= logrotate-entry-base
log = ${redis:log}/*.log
name = redis
################
# Peertube #
################
[peertube-passwd] [peertube-passwd]
recipe = slapos.cookbook:generate.password recipe = slapos.cookbook:generate.password
storage-path = {{ directory_etc }}/.peertube_user storage-path = ${directory:etc}/.peertube_user
bytes = 8 bytes = 8
username = root username = root
[peertube-yaml] [peertube-yaml]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${template-peertube-yaml:output} url = {{ template_peertube_yaml }}
output = {{ directory_config }}/peertube.yaml output = ${directory:config}/peertube.yaml
[peertube-listen-promise] [peertube-listen-promise]
<= monitor-promise-base <= monitor-promise-base
promise = check_url_available promise = check_url_available
name = peertube_listen.py name = peertube_listen.py
config-verify = 0 config-verify = 0
config-url = https://$${frontend:connection-domain} config-url = https://${frontend:connection-domain}
[peertube-service] [peertube-service]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${template-peertube-service:output} url = {{ tempalte_peertube_service }}
output = {{ directory_services }}/peertube output = ${directory:services}/peertube
[peertube-database-resiliency-exclude-file]
recipe = slapos.recipe.template:jinja2
inline = {{ "${postgresql:pgdata-directory}/**" }}
output = ${directory:srv}/exporter.exclude
[peertube-database-resiliency-after-import-script]
recipe = collective.recipe.template
input = inline: #!/bin/sh
${postgresql:bin}/pg_restore -h ${postgresql:pgdata-directory} -c -U peertube -d peertube_prod ${directory:peertube_directory}/peertube_prod-dump.db
output = ${directory:srv}/runner-import-restore
mode = 755
#################################
# Cron service #
#################################
[dcron-service]
recipe = slapos.recipe.template
url = {{ template_dcron_service }}
output = ${directory:services}/crond
logfile = ${directory:log}/crond.log
[peertube-backup-script]
recipe = slapos.recipe.template
url = {{ tempalte_peertube_backup }}
output = ${directory:etc}/${:_buildout_section_name_}
[peertube-backup-cron]
recipe = slapos.recipe.template
url = {{ template_crontab_line }}
output = ${directory:cron-lines}/${:_buildout_section_name_}
script = ${peertube-backup-script:output}
frequency = daily
[activate-crontab-file]
# XXX File is never removed
recipe = plone.recipe.command
stop-on-error = true
command = {{ coreutils_cat }} {{ template_crontab }} ${peertube-backup-cron:output} | {{ dcron_output }} -c ${directory:crontabs} -
[frontend] [frontend]
<= slap-connection <= slap-connection
...@@ -48,17 +220,18 @@ state = stopped ...@@ -48,17 +220,18 @@ state = stopped
{% endif -%} {% endif -%}
config-type = websocket config-type = websocket
config-websocket-path-list = /socket.io /socket /tracker/socket config-websocket-path-list = /socket.io /socket /tracker/socket
config-url = https://[{{ nginx_ip }}]:{{ nginx_port }} config-url = https://[${nginx-configuration:ip}]:${nginx-configuration:port}
return = domain secure_access return = domain secure_access
[peertube-parameters] [peertube-parameters]
recipe = slapos.recipe.build recipe = slapos.recipe.build
slapparameter-dict = {{ slapparameter_dict }} slapparameter-dict = {{ dumps(slapparameter_dict) }}
default-frontend-url = $${frontend:config-url} default-frontend-url = ${frontend:config-url}
working-dir = ${peertube:location} working-dir = {{ peertube_location }}
node-config-dir={{ directory_config }} ipv4-port=9000
node-config-dir=${directory:config}
node-env=production node-env=production
npm-bin=${nodejs:location}/bin/npm npm-bin={{ nodejs_location }}/bin/npm
default-parameters = default-parameters =
{ {
"name" : "Peertube in Slapos", "name" : "Peertube in Slapos",
...@@ -103,8 +276,8 @@ init = ...@@ -103,8 +276,8 @@ init =
[publish-connection-parameter] [publish-connection-parameter]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
frontend-hostname = $${frontend:connection-domain} frontend-hostname = ${frontend:connection-domain}
backend-url = $${frontend:config-url} backend-url = ${frontend:config-url}
frontend-url = $${peertube-parameters:frontend-url} frontend-url = ${peertube-parameters:frontend-url}
password = $${peertube-passwd:passwd} password = ${peertube-passwd:passwd}
username = root username = root
[buildout] [buildout]
extends =
{{ monitor_template_output }}
parts = parts =
service-redis switch-softwaretype
promise-redis
postgresql
postgresql-binary-link
nginx-service
dcron-service
activate-crontab-file
peertube-backup-cron
peertube-database-resiliency-after-import-script
peertube-database-resiliency-exclude-file
nginx-listen-promise
eggs-directory = {{ eggs_directory }} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = {{ develop_eggs_directory }} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
[directory]
recipe = slapos.cookbook:mkdirectory
etc = ${buildout:directory}/etc
srv = ${buildout:directory}/srv
var = ${buildout:directory}/var
log = ${:var}/log
run = ${:var}/run
www = ${:var}/www
crontabs = ${:etc}/crontabs
cron-entries = ${:etc}/cron.d
cronstamps = ${:etc}/cronstamps
cron-lines = ${:etc}/cron.lines
nginx = ${:etc}/nginx
peertube_nginx_log = ${:log}/nginx
varnginx = ${:var}/nginx
services = ${:etc}/service
peertube_directory = ${:www}/peertube
config = ${:peertube_directory}/config
storage = ${:peertube_directory}/storage
versions = ${:peertube_directory}/versions
ssl = ${:etc}/ssl
[peertube] [peertube]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
url = {{ instance_peertube }} url = ${instance-peertube:target}
output = ${buildout:directory}/instance-peertube.cfg output = $${buildout:directory}/instance-peertube.cfg
extensions = jinja2.ext.do
context = context =
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory key eggs_directory buildout:eggs-directory
key develop_eggs_directory buildout:develop-eggs-directory
raw monitor_template ${monitor2-template:output}
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
key nginx_ip nginx-configuration:ip raw ipv6_random $${slap-configuration:ipv6-random}
key nginx_port nginx-configuration:port raw ipv4_random $${slap-configuration:ipv4-random}
raw directory_etc ${directory:etc} raw template_peertube_yaml ${template-peertube-yaml:output}
raw directory_config ${directory:config} raw template_nginx_configration ${template-nginx-configuration:output}
raw directory_services ${directory:services} raw tempalte_peertube_service ${template-peertube-service:output}
ipv4_port = 9000 raw postgresql10_location ${postgresql10:location}
raw tempalte_nginx_service ${template-nginx-service:output}
[postgresql-password] raw redis_binprefix ${redis28:location}/bin
recipe = slapos.cookbook:generate.password raw template_dcron_service ${template-dcron-service:output}
raw tempalte_peertube_backup ${template-peertube-backup-script:output}
[postgresql] raw template_crontab_line ${template-crontab-line:output}
recipe = slapos.cookbook:postgres raw coreutils_cat ${coreutils-output:cat}
bin = {{ postgresql10_location }}/bin/ raw template_crontab ${template-crontab:output}
services = ${directory:services} raw dcron_output ${dcron-output:crontab}
dbname = peertube_prod raw peertube_location ${peertube:location}
superuser = peertube raw nodejs_location ${nodejs:location}
password = ${postgresql-password:passwd}
pgdata-directory = ${directory:srv}/postgresql [switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
ipv4 = ${instance-parameter:ipv4-random} RootSoftwareInstance = $${:default}
# disable listening on ipv6 default = peertube:output
ipv6 =
port = 5432
[postgresql-binary-link]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:bin}
link-binary = ${postgresql:bin}/postgres ${postgresql:bin}/psql
#################################
# Nginx service
#################################
[nginx-service]
recipe = slapos.recipe.template
url = {{ tempalte_nginx_service }}
output = ${directory:services}/nginx
virtual-depends =
${nginx-configuration:ip}
[nginx-listen-promise]
<= monitor-promise-base
promise = check_url_available
name = nginx_listen.py
config-verify = 0
config-url = https://[${nginx-configuration:ip}]:${nginx-configuration:port}
[nginx-configuration]
recipe = slapos.recipe.template
url = {{ template_nginx_configration }}
output = ${directory:etc}/nginx.cfg
access_log = ${directory:log}/nginx-access.log
error_log = ${directory:log}/nginx-error.log
ip = ${instance-parameter:ipv6-random}
port = 9443
ssl_key = ${directory:ssl}/nginx.key
ssl_csr = ${directory:ssl}/nginx.csr
ssl_crt = ${directory:ssl}/nginx.crt
#############
# Redis #
#############
[redis]
recipe = slapos.cookbook:mkdirectory
srv = ${directory:srv}/redis
log = ${directory:log}/redis
[service-redis]
recipe = slapos.cookbook:redis.server
wrapper = ${directory:services}/redis
promise-wrapper = ${directory:bin}/redis-promise
server-dir = ${redis:srv}
config-file = ${directory:etc}/redis.conf
log-file = ${redis:log}/redis.log
pid-file = ${directory:run}/redis.pid
use-passwd = false
unixsocket = ${:server-dir}/redis.socket
# port = 0 means "don't listen on TCP at all" - listen only on unix socket
ipv6 = ::1
port = 0
# server-bin = ${buildout:parts-directory}/redis/bin/redis-server
server-bin = {{ redis_binprefix }}/redis-server
cli-bin = {{ redis_binprefix }}/redis-cli
depend =
${logrotate-entry-redis:recipe}
[promise-redis]
<= monitor-promise-base
promise = check_command_execute
name = promise-redis.py
config-command = ${service-redis:promise-wrapper}
[logrotate-entry-redis]
<= logrotate-entry-base
log = ${redis:log}/*.log
name = redis
#################################
# Cron service
#################################
[dcron-service]
recipe = slapos.recipe.template
url = {{ template_dcron_service }}
output = ${directory:services}/crond
logfile = ${directory:log}/crond.log
[peertube-backup-script]
recipe = slapos.recipe.template
url = {{ tempalte_peertube_backup }}
output = ${directory:etc}/${:_buildout_section_name_}
[peertube-backup-cron]
recipe = slapos.recipe.template
url = {{ template_crontab_line }}
output = ${directory:cron-lines}/${:_buildout_section_name_}
script = ${peertube-backup-script:output}
frequency = daily
[activate-crontab-file]
# XXX File is never removed
recipe = plone.recipe.command
stop-on-error = true
command = {{ coreutils_cat }} {{ template_crontab }} ${peertube-backup-cron:output} | {{ dcron_output }} -c ${directory:crontabs} -
[peertube-database-resiliency-exclude-file]
recipe = slapos.recipe.template:jinja2
inline = {{ "${postgresql:pgdata-directory}/**" }}
output = ${directory:srv}/exporter.exclude
[peertube-database-resiliency-after-import-script]
recipe = collective.recipe.template
input = inline: #!/bin/sh
${postgresql:bin}/pg_restore -h ${postgresql:pgdata-directory} -c -U peertube -d peertube_prod ${directory:peertube_directory}/peertube_prod-dump.db
output = ${directory:srv}/runner-import-restore
mode = 755
#################################
# SlapOS service
#################################
[instance-parameter]
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._ = {}
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration.serialised
computer = ${slap_connection:computer_id} computer= $${slap-connection:computer-id}
partition = ${slap_connection:partition_id} partition=$${slap-connection:partition-id}
url = ${slap_connection:server_url} url = $${slap-connection:server-url}
key = ${slap_connection:key_file} key = $${slap-connection:key-file}
cert = ${slap_connection:cert_file} cert = $${slap-connection:cert-file}
...@@ -58,7 +58,6 @@ parts = ...@@ -58,7 +58,6 @@ parts =
peertube peertube
peertube-build peertube-build
instance-profile instance-profile
instance-peertube
[nodejs] [nodejs]
<= nodejs-16.13.2 <= nodejs-16.13.2
...@@ -83,37 +82,15 @@ post-install = ...@@ -83,37 +82,15 @@ post-install =
rm -rf ${buildout:directory}/.cache/yarn/ rm -rf ${buildout:directory}/.cache/yarn/
rm -rf ${buildout:directory}/parts/peertube/client/node_modules/chromedriver/ rm -rf ${buildout:directory}/parts/peertube/client/node_modules/chromedriver/
[peertube-postgresql-setup.in]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_}
destination = ${buildout:directory}/${:_buildout_section_name_}
[instance-profile] [instance-profile]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/instance.cfg output = ${buildout:directory}/instance.cfg
context =
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory
raw template_nginx_configration ${template-nginx-configuration:output}
raw monitor_template_output ${monitor-template:output}
raw instance_peertube ${instance-peertube:output}
raw postgresql10_location ${postgresql10:location}
raw tempalte_nginx_service ${template-nginx-service:output}
raw redis_binprefix ${redis28:location}/bin
raw template_dcron_service ${template-dcron-service:output}
raw tempalte_peertube_backup ${template-peertube-backup-script:output}
raw template_crontab_line ${template-crontab-line:output}
raw coreutils_cat ${coreutils-output:cat}
raw template_crontab ${template-crontab:output}
raw dcron_output ${dcron-output:crontab}
raw template_peertube_yaml ${template-peertube-yaml:output}
raw template_peertube_service ${template-peertube-service:output}
[instance-peertube] [instance-peertube]
recipe = slapos.recipe.template recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:_update_hash_filename_}
output = ${buildout:directory}/instance-peertube.cfg.in destination = ${buildout:directory}/${:_buildout_section_name_}
[template-peertube-service] [template-peertube-service]
recipe = slapos.recipe.template recipe = slapos.recipe.template
......
...@@ -51,11 +51,12 @@ http { ...@@ -51,11 +51,12 @@ http {
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
upstream backend { upstream backend {
server $${instance-parameter:ipv4-random}:$${peertube:ipv4_port}; server $${slap-configuration:ipv4-random}:$${peertube-parameters:ipv4-port};
} }
server { server {
listen [$${nginx-configuration:ip}]:$${nginx-configuration:port}; listen [$${nginx-configuration:ip}]:$${nginx-configuration:port};
#$${nginx-configuration:ipv6}
access_log $${directory:peertube_nginx_log}/peertube.access.log; # reduce I/0 with buffer=10m flush=5m access_log $${directory:peertube_nginx_log}/peertube.access.log; # reduce I/0 with buffer=10m flush=5m
error_log $${directory:peertube_nginx_log}/peertube.error.log; error_log $${directory:peertube_nginx_log}/peertube.error.log;
......
listen: listen:
hostname: '$${instance-parameter:ipv4-random}' hostname: '$${slap-configuration:ipv4-random}'
port: $${peertube-parameters:ipv4-port} port: $${peertube-parameters:ipv4-port}
# Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL) # Correspond to your reverse proxy server_name/listen configuration (i.e., your public PeerTube instance URL)
webserver: webserver:
https: true https: true
# hostname: 'softinst176929.host.vifib.net'
# port: 443
hostname: '$${peertube-parameters:host}' hostname: '$${peertube-parameters:host}'
port: $${peertube-parameters:port} port: $${peertube-parameters:port}
......
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