diff --git a/conf/30-peertube-tcp.conf b/conf/30-peertube-tcp.conf new file mode 100644 index 0000000..6cded79 --- /dev/null +++ b/conf/30-peertube-tcp.conf @@ -0,0 +1,8 @@ +# In a video server, we are often sending files to a client +# which can't accept it as fast as our local network connection +# could produce packets. To prevent packet loss and buffer bloat, +# it's especially important to use a modern CoDel scheduler which +# knows how to delay outgoing packets to match slower client links. + +net.core.default_qdisc = fq_codel +net.ipv4.tcp_congestion_control = bbr diff --git a/scripts/install b/scripts/install index ae188e3..1697c6c 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ path_url="/" admin_email=$YNH_APP_ARG_EMAIL admin_pass=$(ynh_string_random 24) is_public=$YNH_APP_ARG_IS_PUBLIC +tuning="1" # This is a multi-instance app, meaning it can be installed several times independently @@ -60,7 +61,7 @@ ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" admin_email "$admin_email" ynh_app_setting_set "$app" admin_pass "$admin_pass" ynh_app_setting_set "$app" is_public "$is_public" - +ynh_app_setting_set "$app" tuning "$tuning" #================================================= # STANDARD MODIFICATIONS #================================================= @@ -190,6 +191,20 @@ ynh_store_file_checksum "$final_path/config/production.yaml" # Use logrotate to manage application logfile(s) ynh_use_logrotate "/home/yunohost.app/${app}/storage/logs/peertube.log" +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +### `yunohost service add` is a CLI yunohost command to add a service in the admin panel. +### You'll find the service in the 'services' section of YunoHost admin panel. +### This CLI command would be useless if the app does not have any services (systemd or sysvinit) +### If you're not using these lines: +### - You can remove these files in conf/. +### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script +### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script + +yunohost service add NAME_INIT.D --log "/home/yunohost.app/${app}/storage/logs/peertube.log" + #================================================= # SETUP SSOWAT #================================================= @@ -214,8 +229,6 @@ chown -R "$app":"$app" "$final_path" "$datadir" systemctl reload nginx - - #================================================= # SETUP SYSTEMD #================================================= @@ -237,6 +250,17 @@ systemctl start "$app" echo $admin_pass | NODE_CONFIG_DIR="$final_path/config" NODE_ENV=production npm run reset-password -- -u root ) +#================================================= +# TUNING CONFIGURATION +#================================================= +if [ $tuning -eq 1 ] +then + +# Copy 30-peertube-tcp to /etc/sysctl.d/ + cp -f ../30-peertube-tcp.conf /etc/sysctl.d/ + sysctl -p /etc/sysctl.d/30-peertube-tcp.conf +fi + #================================================= # SEND A README FOR THE ADMIN #================================================= diff --git a/scripts/remove b/scripts/remove index 7b1b909..891a51a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -101,6 +101,14 @@ fi # Delete a system user ynh_system_user_delete "$app" +# Remove 30-peertube-tcp.conf +if [ -f /etc/sysctl.d/30-peertube-tcp.conf ]; then + + # Remove 30-peertube-tcp from /etc/sysctl.d/ + rm -f /etc/sysctl.d/30-peertube-tcp.conf + sysctl -p +fi + #================================================= # SEND A README FOR THE ADMIN #================================================= diff --git a/scripts/restore b/scripts/restore index a3ea65c..b92d5fb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -136,6 +136,11 @@ ynh_restore_file "/etc/logrotate.d/$app" # Set right permissions chown -R "$app":"$app" "$final_path" +# TUNING CONFIGURATION +# Copy 30-peertube-tcp to /etc/sysctl.d/ +cp -f ../30-peertube-tcp.conf /etc/sysctl.d/ +sysctl -p /etc/sysctl.d/30-peertube-tcp.conf + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1ff822b..978d416 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -196,6 +196,12 @@ then ynh_app_setting_set "$app" unprotected_uris "/" fi + +# TUNING CONFIGURATION +# Copy 30-peertube-tcp to /etc/sysctl.d/ +cp -f ../30-peertube-tcp.conf /etc/sysctl.d/ +sysctl -p /etc/sysctl.d/30-peertube-tcp.conf + #================================================= # RELOAD NGINX #=================================================