Skip to content

Commit

Permalink
Add RAMDISK_STORAGE_ENABLED config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Whybrow committed Nov 4, 2012
1 parent ea0d49b commit 748b474
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 8 additions & 5 deletions init/msm
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,14 @@ log_line_get_time() {
# Moves a world to RAM
# $1: the ID of the world to move
world_to_ram() {
manager_property RAMDISK_STORAGE_ENABLED
manager_property RAMDISK_STORAGE_PATH
server_property "${WORLD_SERVER_ID[$1]}" USERNAME
world_property "$1" RAMDISK_PATH
world_property "$1" FLAG_INRAM
world_property "$1" PATH

if [ ! -z "$SETTINGS_RAMDISK_STORAGE_PATH" ]; then
if [[ "$SETTINGS_RAMDISK_STORAGE_ENABLED" == "true" ]; then
as_user "${SERVER_USERNAME[${WORLD_SERVER_ID[$1]}]}" "mkdir -p \"${WORLD_RAMDISK_PATH[$1]}\" && rsync -rt --exclude '$(basename "${WORLD_FLAG_INRAM[$1]}")' \"${WORLD_PATH[$1]}/\" \"${WORLD_RAMDISK_PATH[$1]}\""
fi
}
Expand Down Expand Up @@ -485,9 +486,10 @@ world_property() {
WORLD_BACKUP_PATH[$1]="$SETTINGS_WORLD_ARCHIVE_PATH/${SERVER_NAME[$sid]}/${WORLD_NAME[$1]}"
;;
RAMDISK_PATH)
manager_property RAMDISK_STORAGE_PATH
manager_property RAMDISK_STORAGE_ENABLED
# If the ramdisk path is set, get the path for this world
if [ ! -z "$SETTINGS_RAMDISK_STORAGE_PATH" ]; then
if [[ "$SETTINGS_RAMDISK_STORAGE_ENABLED" == "true" ]]; then
manager_property RAMDISK_STORAGE_PATH
WORLD_RAMDISK_PATH[$1]="${SETTINGS_RAMDISK_STORAGE_PATH}/${SERVER_NAME[$sid]}/${WORLD_NAME[$1]}"
fi
;;
Expand Down Expand Up @@ -690,7 +692,7 @@ server_worlds_to_ram() {
manager_property RAMDISK_STORAGE_PATH

# Only proceed if there is a ramdisk path set in config
if [ ! -z "$SETTINGS_RAMDISK_STORAGE_PATH" ]; then
if [[ "$SETTINGS_RAMDISK_STORAGE_ENABLED" == "true" ]]; then
echo -n "Synchronising flagged worlds on disk to RAM... "
local i="${SERVER_WORLD_OFFSET[$1]}"
local max="$(( $i + ${SERVER_NUM_WORLDS[$1]} ))"
Expand All @@ -715,7 +717,7 @@ server_worlds_to_ram() {
server_worlds_to_disk() {
manager_property RAMDISK_STORAGE_PATH

if [ ! -z "$SETTINGS_RAMDISK_STORAGE_PATH" ]; then
if [[ "$SETTINGS_RAMDISK_STORAGE_ENABLED" == "true" ]]; then
echo -n "Synchronising worlds in RAM to disk... "
local i="${SERVER_WORLD_OFFSET[$1]}"
local max="$(( $i + ${SERVER_NUM_WORLDS[$1]} ))"
Expand Down Expand Up @@ -3152,6 +3154,7 @@ register_settings() {
register_setting JAR_STORAGE_PATH "/opt/msm/jars"
register_setting VERSIONING_STORAGE_PATH "/opt/msm/versioning"
register_setting VERSIONING_FILE_EXTENSION "sh"
register_setting RAMDISK_STORAGE_ENABLED "false"
register_setting RAMDISK_STORAGE_PATH "/dev/shm/msm"

register_setting UPDATE_URL "https://raw.github.com/marcuswhybrow/minecraft-server-manager/latest"
Expand Down
6 changes: 5 additions & 1 deletion msm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ JAR_STORAGE_PATH="/opt/msm/jars"
VERSIONING_STORAGE_PATH="/opt/msm/versioning"


# Change this to "true" to allow MSM to use RAMDisk for storing worlds.
# Note: RAMDisk will only be used for worlds enabled as "in ram".
RAMDISK_STORAGE_ENABLED="false"

# Where RAM enambled worlds are stored
# This needs to be a path located inside the mounted ramdisk for your system
# under Ubuntu this would be "/dev/shm", so "/dev/shm/msm" would be a good
# location. If left blank RAM disk will not be used.
# location. This is ignored if RAMDISK_STORAGE_ENABLED is not "true"
RAMDISK_STORAGE_PATH="/dev/shm/msm"


Expand Down

0 comments on commit 748b474

Please sign in to comment.