From 9b7f7e1da40d48c972b56ca65dd658d08afe3b1f Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 25 Mar 2021 22:38:06 +0100 Subject: [PATCH] Fix --- conf/systemd.service | 7 +++++-- scripts/_common.sh | 10 +++++----- scripts/install | 15 +++++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index f6a38cb..57b4d84 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,9 +9,12 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ #PIDFile=/path/to/nodebb/pidfile -Environment=NODE_ENV=production +Environment="NODE_ENV=production" +Environment="__YNH_NODE_LOAD_PATH__" + #ExecStart=__NODE__/node loader.js --no-daemon --no-silent -ExecStart=__YNH_NPM__ start +ExecStart= start + Restart=always [Install] diff --git a/scripts/_common.sh b/scripts/_common.sh index e2f042b..1382e95 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,15 +22,15 @@ nodejs_version=14 #================================================= # Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local user=$1 +# usage: ynh_exec_as USER COMMAND [ARG ...] +ynh_exec_as() { + local USER=$1 shift 1 - if [[ $user = $(whoami) ]]; then + if [[ $USER = $(whoami) ]]; then eval "$@" else - sudo -u "$user" "$@" + sudo -u "$USER" "$@" fi } diff --git a/scripts/install b/scripts/install index aaa863b..4297d46 100644 --- a/scripts/install +++ b/scripts/install @@ -124,10 +124,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" -ynh_add_systemd_config +ynh_add_systemd_config --others_var="ynh_node_load_PATH" #================================================= # CONFIGURE SERVER.JS @@ -142,9 +142,12 @@ ynh_add_config --template="../conf/config.json" --destination="$final_path/confi chown -R $app:$app $final_path pushd $final_path - exec_as $app ./nodebb setup -l > $install_log - exec_as $app npm install nodebb-plugin-dbsearch --save-prod - exec_as $app ./nodebb build -l + ynh_exec_as $app env $ynh_node_load_PATH ./nodebb setup -l > $install_log + ynh_exec_as $app env $ynh_node_load_PATH npm install nodebb-plugin-dbsearch --save-prod + ynh_exec_as $app env $ynh_node_load_PATH ./nodebb build -l + #exec_as $app ./nodebb setup -l > $install_log + #exec_as $app npm install nodebb-plugin-dbsearch --save-prod + #exec_as $app ./nodebb build -l popd