Skip to content

Commit 9aa55ae

Browse files
committed
fix timeout taking too long
1 parent 170e864 commit 9aa55ae

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

modules/jellyfin/default.nix

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ in {
236236
echo "First run detected - generating migrations.xml"
237237
${pkgs.xmlstarlet}/bin/xmlstarlet ed -L -u "//IsStartupWizardCompleted" -v "false" '${cfg.configDir}/system.xml'
238238
239-
${getExe cfg.package} --datadir '${cfg.dataDir}' --configdir '${cfg.configDir}' --cachedir '${cfg.cacheDir}' --logdir '${cfg.logDir}' &
240-
JELLYFIN_PID=$!
239+
${getExe cfg.package} --datadir '${cfg.dataDir}' --configdir '${cfg.configDir}' --cachedir '${cfg.cacheDir}' --logdir '${cfg.logDir}' & disown
241240
242241
echo "Waiting for migrations.xml to be generated..."
243242
until [ -f "${cfg.configDir}/migrations.xml" ]; do
@@ -246,8 +245,10 @@ in {
246245
sleep 3
247246
248247
echo "Stopping temporary Jellyfin instance..."
249-
kill -15 $JELLYFIN_PID || true
250-
wait $JELLYFIN_PID || true
248+
${pkgs.procps}/bin/pkill -15 -f ${cfg.package}
249+
while ${pkgs.procps}/bin/ps ax | ${pkgs.gnugrep}/bin/grep -v grep | ${pkgs.gnugrep}/bin/grep -q ${cfg.package}; do
250+
sleep 1
251+
done
251252
252253
echo "Restoring IsStartupWizardCompleted to true"
253254
${pkgs.xmlstarlet}/bin/xmlstarlet ed -L -u "//IsStartupWizardCompleted" -v "true" '${cfg.configDir}/system.xml'
@@ -257,8 +258,7 @@ in {
257258
${optionalString (cfg.users != {}) ''
258259
if [ ! -e "${dbPath}" ]; then
259260
echo "Database does not exist, starting Jellyfin to create it..."
260-
${getExe cfg.package} --datadir '${cfg.dataDir}' --configdir '${cfg.configDir}' --cachedir '${cfg.cacheDir}' --logdir '${cfg.logDir}' &
261-
JELLYFIN_PID=$!
261+
${getExe cfg.package} --datadir '${cfg.dataDir}' --configdir '${cfg.configDir}' --cachedir '${cfg.cacheDir}' --logdir '${cfg.logDir}' & disown
262262
263263
echo "Waiting for database to be created..."
264264
until [ -f "${dbPath}" ]; do
@@ -267,8 +267,10 @@ in {
267267
sleep 3
268268
269269
echo "Stopping Jellyfin..."
270-
kill -15 $JELLYFIN_PID || true
271-
wait $JELLYFIN_PID || true
270+
${pkgs.procps}/bin/pkill -15 -f ${cfg.package}
271+
while ${pkgs.procps}/bin/ps ax | ${pkgs.gnugrep}/bin/grep -v grep | ${pkgs.gnugrep}/bin/grep -q ${cfg.package}; do
272+
sleep 1
273+
done
272274
fi
273275
274276
dbcmds=$(${pkgs.coreutils}/bin/mktemp)

0 commit comments

Comments
 (0)