Commit d9f64adb authored by Boxiang Sun's avatar Boxiang Sun

peertube

parent 317abe56
...@@ -20,6 +20,10 @@ filename = instance.cfg.in ...@@ -20,6 +20,10 @@ filename = instance.cfg.in
filename = template-nginx-service.sh.in filename = template-nginx-service.sh.in
md5sum = 458870b70c33a1621b68961ae2372ad5 md5sum = 458870b70c33a1621b68961ae2372ad5
[template-peertube-service]
filename = template-peertube-service.sh.in
# md5sum = 458870b70c33a1621b68961ae2372ad5
[template-nginx-configuration] [template-nginx-configuration]
filename = template-nginx.cfg.in filename = template-nginx.cfg.in
md5sum = 6b11e79bcc7734d8629e1b6e6cb497e1 # md5sum = 6b11e79bcc7734d8629e1b6e6cb497e1
...@@ -9,7 +9,9 @@ parts = ...@@ -9,7 +9,9 @@ parts =
postgresql-extension postgresql-extension
nginx-service nginx-service
nginx-listen-promise nginx-listen-promise
peertube-configuration-1 peertube-service
peertube-configuration
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
...@@ -23,6 +25,9 @@ var = $${buildout:directory}/var ...@@ -23,6 +25,9 @@ var = $${buildout:directory}/var
log = $${:var}/log log = $${:var}/log
run = $${:var}/run run = $${:var}/run
www = $${:srv}/www www = $${:srv}/www
nginx = $${:etc}/nginx
nginx_sites-available = $${:nginx}/sites-available
nginx_sites-enabled = $${:nginx}/sites-enabled
varnginx = $${:var}/nginx varnginx = $${:var}/nginx
services = $${:etc}/service services = $${:etc}/service
peertube_directory = $${:srv}/var/www/peertube peertube_directory = $${:srv}/var/www/peertube
...@@ -31,45 +36,55 @@ storage = $${:var}/www/peertube/storage ...@@ -31,45 +36,55 @@ storage = $${:var}/www/peertube/storage
versions = $${:var}/www/peertube/versions versions = $${:var}/www/peertube/versions
ssl = $${:etc}/ssl ssl = $${:etc}/ssl
[peertube-configuration-1] [peertube-configuration]
recipe = slapos.recipe.build recipe = slapos.recipe.build
production_config_template = ${peertube:location}/config/production.yaml.example production_config_template = ${peertube:location}/config/production.yaml.example
peertube_directory = $${directory:peertube_directory}
production_config_prod = $${directory:config}/production.yaml production_config_prod = $${directory:config}/production.yaml
default_yaml = ${peertube:location}/config/default.yaml default_yaml = ${peertube:location}/config/default.yaml
default_yaml_prod = $${directory:config}/default.yaml default_yaml_prod = $${directory:config}/default.yaml
nginx_config = ${peertube:location}/support/nginx/peertube nginx_sites-available = ${peertube:location}/support/nginx/peertube
nginx_config_prod = ${peertube:location}/support/nginx/peertube nginx_sites-available_prod = $${directory:nginx_sites-available}/peertube
nginx_sites-enabled_prod = $${directory:nginx_sites-enabled}/peertube
peertube_service = ${peertube:location}/support/systemd/peertube.service
peertube_service_prod = $${directory:services}/peertube.service
peertube_config = $${directory:config}
peertube_code_dir = ${peertube:location}
install = install =
import shutil import shutil, os
shutil.copyfile(options['default_yaml'], options['default_yaml_prod']) shutil.copyfile(options['default_yaml'], options['default_yaml_prod'])
shutil.copyfile(options['default_yaml'], options['default_yaml_prod'])
with open(options['production_config_template'], "r", encoding='utf-8') as exmaple_file: with open(options['nginx_sites-available'], "r", encoding='utf-8') as example_file:
with open(options['nginx_sites-available_prod'], "w", encoding='utf-8') as prod_file:
for line in example_file:
if "WEBSERVER_HOST" in line:
line = line.replace('$', '')
line = line.replace("{WEBSERVER_HOST}", "https://[$${nginx-configuration:ip}]/$${nginx-configuration:port}")
if "{PEERTUBE_HOST}" in line:
line = line.replace('$', '')
line = line.replace("{PEERTUBE_HOST}", "127.0.0.1:9000")
if "ssl_certificate" in line:
line = ''
prod_file.write(line)
if not os.path.exists(options['nginx_sites-enabled_prod']):
os.symlink(options['nginx_sites-available_prod'], options['nginx_sites-enabled_prod'])
with open(options['production_config_template'], "r", encoding='utf-8') as example_file:
with open(options['production_config_prod'], "w", encoding='utf-8') as prod_file: with open(options['production_config_prod'], "w", encoding='utf-8') as prod_file:
for line in exmaple_file: for line in example_file:
if "hostname: 'example.com'" in line: if "hostname: 'example.com'" in line:
line = line.replace("example.com", "https://[$${nginx-configuration:ip}]/$${nginx-configuration:port}") line = line.replace("example.com", "https://[$${nginx-configuration:ip}]/$${nginx-configuration:port}")
if "password: 'peertube'" in line: if "password: 'peertube'" in line:
line = line.replace("peertube", "$${postgresql:password}") line = line.replace("peertube", "$${postgresql:password}")
print("Fuck!!!") if "/var/www/peertube" in line:
print(line) line = line.replace("/var/www/peertube", options['peertube_directory'])
prod_file.write(line) prod_file.write(line)
# content = content.replace(old_content, new_content) [peertube-service]
recipe = slapos.recipe.template
url = ${template-peertube-service:output}
[peertube-configuration] output = $${directory:services}/peertube
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line = echo "Hello!"
cd ${peertube:location}
cp ${peertube:location}/config/production.yaml.example ${peertube:location}/config/production.yaml
# Change config/production.yaml
environment =
PATH=${unzip:location}/bin:${vim:location}/bin:${nodejs:location}/bin:${yarn:location}/bin:${python3:location}/bin:${nginx:location}/sbin:${postgresql:location}/sbin:${gcc-10.2:location}/bin:${redis:location}/bin:{git:location}/bin:{wget:location}/bin:%(PATH)s
CPPFLAGS=-I${openssl:location}/include
LDFLAGS=-L${curl:location}/lib -Wl,-rpath -Wl,${openssl:location}/lib -Wl,-rpath -Wl
[postgresql-password] [postgresql-password]
recipe = slapos.cookbook:generate.password recipe = slapos.cookbook:generate.password
...@@ -124,6 +139,8 @@ url = ${template-nginx-configuration:output} ...@@ -124,6 +139,8 @@ url = ${template-nginx-configuration:output}
output = $${directory:etc}/nginx.cfg output = $${directory:etc}/nginx.cfg
access_log = $${directory:log}/nginx-access.log access_log = $${directory:log}/nginx-access.log
error_log = $${directory:log}/nginx-error.log error_log = $${directory:log}/nginx-error.log
nginx_sites-available = $${directory:nginx_sites-available}/peertube
nginx_sites-enabled = $${directory:nginx_sites-enabled}/peertube
ip = $${instance-parameter:ipv6-random} ip = $${instance-parameter:ipv6-random}
port = 9443 port = 9443
ssl_key = $${directory:ssl}/nginx.key ssl_key = $${directory:ssl}/nginx.key
......
...@@ -73,13 +73,18 @@ environment = ...@@ -73,13 +73,18 @@ environment =
pre-configure = pre-configure =
${yarn:location}/bin/yarn install --production --pure-lockfile ${yarn:location}/bin/yarn install --production --pure-lockfile
configure-command = true configure-command = true
make-binary = cd %(location)s && ${yarn:location}/bin/yarn make-binary = cd ${peertube:location} && ${yarn:location}/bin/yarn
[instance-profile] [instance-profile]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/instance.cfg output = ${buildout:directory}/instance.cfg
[template-peertube-service]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/${:filename}
[template-nginx-service] [template-nginx-service]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
......
...@@ -16,6 +16,9 @@ http { ...@@ -16,6 +16,9 @@ http {
# Basic Settings # Basic Settings
## ##
include $${nginx-configuration:nginx_sites-available};
include $${nginx-configuration:nginx_sites-enabled};
sendfile on; sendfile on;
tcp_nopush on; tcp_nopush on;
tcp_nodelay on; tcp_nodelay on;
......
exec cd ${peertube:location} && \
${nodejs:location}/bin/node \
env NODE_ENV=production NODE_CONFIG_DIR=$${peertube-configuration:peertube_config}\
${peertube:location}/dist/server
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