mirror of
https://github.com/YunoHost-Apps/photoprism_ynh.git
synced 2024-09-03 19:56:41 +02:00
Trying with swap
This commit is contained in:
parent
b5568eeb5e
commit
8d7d47ef07
5 changed files with 38 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
||||||
# Tag name of the installed version
|
# Tag name of the installed version
|
||||||
PHOTOPRISM_VERSION="220528-efb5d710"
|
PHOTOPRISM_VERSION="220528-efb5d710"
|
||||||
|
|
||||||
|
MEMORY_NEEDED="2560"
|
||||||
NODEJS_VERSION=14
|
NODEJS_VERSION=14
|
||||||
GO_VERSION="1.18"
|
GO_VERSION="1.18"
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,22 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION 2>&1
|
||||||
# Install go
|
# Install go
|
||||||
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
|
ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD SWAP IF NEEDED
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Adding swap is needed..."
|
||||||
|
|
||||||
|
total_memory=$(ynh_get_ram --total)
|
||||||
|
swap_needed=0
|
||||||
|
|
||||||
|
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||||
|
# Need a minimum of 2.5Go of memory
|
||||||
|
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||||
|
ynh_add_swap --size=$swap_needed
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -147,7 +163,7 @@ pushd "$final_path"
|
||||||
# Setup tensorflow library
|
# Setup tensorflow library
|
||||||
./scripts/dist/install-tensorflow.sh
|
./scripts/dist/install-tensorflow.sh
|
||||||
# Setup node environment
|
# Setup node environment
|
||||||
export NODE_OPTIONS=--max_old_space_size=800
|
export NODE_OPTIONS=--max_old_space_size=2048
|
||||||
# Build server from source
|
# Build server from source
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
env "$ynh_node_load_PATH" npm install -g npm
|
env "$ynh_node_load_PATH" npm install -g npm
|
||||||
|
|
|
@ -118,6 +118,9 @@ ynh_secure_remove --file="/etc/cron.d/$app"
|
||||||
# Remove the log files
|
# Remove the log files
|
||||||
ynh_secure_remove --file="/var/log/$app"
|
ynh_secure_remove --file="/var/log/$app"
|
||||||
|
|
||||||
|
# Remove swap
|
||||||
|
ynh_del_swap
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -104,6 +104,22 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD SWAP IF NEEDED
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Adding swap is needed..."
|
||||||
|
|
||||||
|
total_memory=$(ynh_get_ram --total)
|
||||||
|
swap_needed=0
|
||||||
|
|
||||||
|
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||||
|
# Need a minimum of 2.5Go of memory
|
||||||
|
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||||
|
ynh_add_swap --size=$swap_needed
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD PHOTOPRISM
|
# BUILD PHOTOPRISM
|
||||||
|
@ -119,7 +135,7 @@ pushd "$final_path"
|
||||||
# Setup tensorflow library
|
# Setup tensorflow library
|
||||||
./scripts/dist/install-tensorflow.sh
|
./scripts/dist/install-tensorflow.sh
|
||||||
# Setup node environment
|
# Setup node environment
|
||||||
export NODE_OPTIONS=--max_old_space_size=800
|
export NODE_OPTIONS=--max_old_space_size=2048
|
||||||
# Build server from source
|
# Build server from source
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
env "$ynh_node_load_PATH" npm install -g npm
|
env "$ynh_node_load_PATH" npm install -g npm
|
||||||
|
|
|
@ -51,7 +51,6 @@ ynh_add_swap () {
|
||||||
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
||||||
if ! fallocate -l ${swap_size}K /swap_$app
|
if ! fallocate -l ${swap_size}K /swap_$app
|
||||||
then
|
then
|
||||||
echo "I'm also in !"
|
|
||||||
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
||||||
fi
|
fi
|
||||||
chmod 0600 /swap_$app
|
chmod 0600 /swap_$app
|
||||||
|
|
Loading…
Add table
Reference in a new issue