From b1fd71038ef53cc3faed23055968baf0b36884bd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 18 Mar 2012 19:05:44 +0000 Subject: [PATCH] * Slight speedup. It's amazing how quickly shell scripts become slow: calling basename in a loop somewhere has a noticable impact on performance. We really shouldn't use bash scripts. svn path=/nixos/trunk/; revision=33242 --- modules/system/activation/switch-to-configuration.sh | 6 ++---- modules/system/activation/top-level.nix | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/system/activation/switch-to-configuration.sh b/modules/system/activation/switch-to-configuration.sh index 371b6835368..8b8ea718666 100644 --- a/modules/system/activation/switch-to-configuration.sh +++ b/modules/system/activation/switch-to-configuration.sh @@ -106,8 +106,7 @@ declare -A noRestartIfChanged=(@noRestartIfChanged@) # all jobs that don't have a "stop" goal.) We use the symlinks in # /var/run/upstart-jobs (created by each job's pre-start script) to # determine if a job has changed. -for job in $(cd $jobsDir && ls *.conf); do - job=$(basename $job .conf) +for job in @jobs@; do status=$(status "$job") if ! [[ "$status" =~ start/ ]]; then continue; fi if [ "$(readlink -f "$jobsDir/$job.conf")" = "$(readlink -f "/var/run/upstart-jobs/$job")" ]; then continue; fi @@ -128,8 +127,7 @@ done # differs from the previous instance of the same task; if it wasn't # previously run, don't run it. If it's a service, only start it if # it has a "start on" condition. -for job in $(cd $jobsDir && ls *.conf); do - job=$(basename $job .conf) +for job in @jobs@; do status=$(status "$job") if ! [[ "$status" =~ stop/ ]]; then continue; fi diff --git a/modules/system/activation/top-level.nix b/modules/system/activation/top-level.nix index df07bc1095a..f1bc4eea597 100644 --- a/modules/system/activation/top-level.nix +++ b/modules/system/activation/top-level.nix @@ -154,6 +154,8 @@ let initScriptBuilder = config.system.build.initScriptBuilder; activationScript = config.system.activationScripts.script; + jobs = map (j: j.name) (attrValues config.jobs); + # Pass the names of all Upstart tasks to the activation script. tasks = attrValues (mapAttrs (n: v: if v.task then ["[${v.name}]=1"] else []) config.jobs);