Skip to content

Commit

Permalink
volume - Allow disabling ramdisk by setting value to off
Browse files Browse the repository at this point in the history
Before, to toggle ramdisk, you had to edit the loco.yml and add/remove block of instructions.

Now, to toggle ramdisk, ou can keep the block of instructions -- but revise the variable RAMDISK_SIZE
  • Loading branch information
totten committed Feb 29, 2024
1 parent e6bf88c commit 009abb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ services:
## dependency before any other services.
volume:
# Setup the data-volume with a ramdisk service
# The special value "off" disables ramdisk service
# Depends: https://github.com/totten/ramdisk
ramdisk: SIZE_IN_MB

Expand Down
4 changes: 2 additions & 2 deletions src/LocoVolume.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class LocoVolume extends LocoService {
public static function create($system, $name, $settings) {
if (!empty($settings['ramdisk'])) {
$defaults = [
'init' => ['ramdisk start "$LOCO_VAR" "$LOCO_RAMDISK"'],
'cleanup' => ['ramdisk stop "$LOCO_VAR"'],
'init' => ['if [ "$LOCO_RAMDISK" != "off" ]; then ramdisk start "$LOCO_VAR" "$LOCO_RAMDISK"; fi'],
'cleanup' => ['if [ "$LOCO_RAMDISK" != "off" ]; then ramdisk stop "$LOCO_VAR" ; else rm "$LOCO_VAR/.loco-volume" ; fi'],
'message' => 'Loco data volume is a ram disk "<comment>$LOCO_VAR</comment>".',
];
$settings = array_merge($defaults, $settings);
Expand Down

0 comments on commit 009abb4

Please sign in to comment.