File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 fi
3535 }
3636
37- # Build JSON config using jq
37+ # Build JSON config using jq with file locking to prevent concurrent writes
3838 CONFIG_FILE="$RESTISH_CONFIG_DIR/apis.json"
39+ LOCK_FILE="$RESTISH_CONFIG_DIR/apis.json.lock"
40+
41+ # Acquire exclusive lock (will wait if another process has it)
42+ exec 200>"$LOCK_FILE"
43+ ${ pkgs . util-linux } /bin/flock 200
3944 ${ lib . concatStringsSep "\n " ( lib . mapAttrsToList ( name : svc : ''
4045 ${ lib . concatStringsSep "\n " ( lib . mapAttrsToList ( k : v : ''
4146 export HEADER_${ sanitizeVarName name } _${ sanitizeVarName k } =$(read_value "${ v } ")
7378 TEMP_CONFIG=$(mktemp)
7479 ${ pkgs . envsubst } /bin/envsubst < "$CONFIG_FILE" > "$TEMP_CONFIG"
7580 mv "$TEMP_CONFIG" "$CONFIG_FILE"
81+
82+ # Release lock
83+ exec 200>&-
7684 '' }
7785
7886 exec ${ pkgs . restish } /bin/restish "$@"
You can’t perform that action at this time.
0 commit comments