Skip to content

Instantly share code, notes, and snippets.

@sonnetmia
Forked from aradhell/swap.config
Created June 1, 2021 13:00
Show Gist options
  • Save sonnetmia/df8ed6230a576652c3d4edd783926d5e to your computer and use it in GitHub Desktop.
Save sonnetmia/df8ed6230a576652c3d4edd783926d5e to your computer and use it in GitHub Desktop.
add swap memory to elastic beanstalk
commands:
create_pre_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/pre"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/00_setup_swap.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
SWAPFILE=/var/swapfile
SWAP_MEGABYTES=4096
if [ -f $SWAPFILE ]; then
echo "Swapfile $SWAPFILE found, skipping"
exit 0;
fi
/bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES
/bin/chmod 600 $SWAPFILE
/sbin/mkswap $SWAPFILE
/sbin/swapon $SWAPFILE
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment