Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos
Commits
80ddc397
Commit
80ddc397
authored
Oct 14, 2022
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
peertube: Configure database
parent
82c2efcf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
14 deletions
+46
-14
software/peertube/instance.cfg.in
software/peertube/instance.cfg.in
+11
-13
software/peertube/template-peertube-service.sh.in
software/peertube/template-peertube-service.sh.in
+35
-1
No files found.
software/peertube/instance.cfg.in
View file @
80ddc397
...
...
@@ -6,7 +6,6 @@ parts =
service-redis
promise-redis
postgresql
postgresql-extension
nginx-service
nginx-listen-promise
peertube-service
...
...
@@ -68,15 +67,21 @@ init =
with open(options['production_config_template'], "r", encoding='utf-8') as config_template_file:
with open(options['production_config_prod'], "w", encoding='utf-8') as config_prod_file:
print('Fuck!!!')
print(options['production_config_template'])
print(options['production_config_prod'])
local_host_counter = 0
for line in config_template_file:
if "hostname: 'example.com'" in line:
line = line.replace("example.com", "https://[$${nginx-configuration:ip}]/$${nginx-configuration:port}")
if "password: 'peertube'" in line:
el
if "password: 'peertube'" in line:
line = line.replace("peertube", "$${postgresql:password}")
if "/var/www/peertube" in line:
elif "hostname: 'localhost'" in line:
local_host_counter += 1
if local_host_counter == 2:
line = line.replace("localhost", "$${postgresql:ipv4}")
if local_host_counter == 3:
line = '' # set 'hostname' and 'port' to null, use redis.socket
elif "6379" in line:
line = line.replace("port: 6379", "unixsocket: $${service-redis:unixsocket}") # set 'hostname' and 'port' to null, use redis.socket
elif "/var/www/peertube" in line:
line = line.replace("/var/www/peertube", "$${directory:peertube_directory}")
config_prod_file.write(line)
...
...
@@ -102,13 +107,6 @@ ipv4 = $${instance-parameter:ipv4-random}
ipv6 =
port = 5432
[postgresql-extension]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:bin}/$${:_buildout_section_name_}
command-line =
$${postgresql:bin}/psql -c "CREATE EXTENSION pg_trgm;" $${postgresql:dbname}
$${postgresql:bin}/psql -c "CREATE EXTENSION unaccent;" $${postgresql:dbname}
[service-postgresql]
recipe = slapos.cookbook:postgres
bin = {{ postgresql_location }}/bin
...
...
software/peertube/template-peertube-service.sh.in
View file @
80ddc397
cd ${peertube:location} &&
exec env NODE_ENV=production NODE_CONFIG_DIR=$${peertube-setup:peertube_config} \
# setup db
die() {
echo "$*" 1>&2
exit 1
}
# run psql on gitlab db
psql() {
$${postgresql:bin}/psql \
-h $${postgresql:pgdata-directory} \
-U $${postgresql:superuser} \
-d $${postgresql:dbname} \
"$@"
}
# initial db setup
# ( first quering PG several times waiting a bit till postgresql is started and ready )
tpgwait=5
while true; do
pgtables="$(psql -c '\d' 2>&1)" && break
tpgwait=$(( $tpgwait - 1 ))
test $tpgwait = 0 && die "pg query problem"
echo "I: PostgreSQL is not ready (yet ?); will retry $tpgwait times..." 1>&2
sleep 1
done
echo "I: PostgreSQL ready." 1>&2
# make sure pg_trgm extension is enabled for peertube db
# $${postgresql:bin}/psql -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;' $${postgresql:dbname} || die "pg_trgm setup failed"
# make sure unaccent extension is enabled for peertube db
# $${postgresql:bin}/psql -c 'CREATE EXTENSION IF NOT EXISTS unaccent;' $${postgresql:dbname} || die "unaccent setup failed"
exec env NODE_ENV=production NODE_CONFIG_DIR=$${peertube-setup:peertube_config} PATH=${ffmpeg:location}/bin:$PATH\
${nodejs:location}/bin/node ${peertube:location}/dist/server
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment