Skip to content

Commit 5c4f496

Browse files
committed
initial vagrant environment with working redis. need to install python next
1 parent c0ca9ad commit 5c4f496

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist/
55
dump.rdb
66
/.tox
77
_build
8+
vagrant/.vagrant

vagrant/Vagrantfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5+
VAGRANTFILE_API_VERSION = "2"
6+
7+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8+
# ubuntu 64bit image
9+
config.vm.box = "hashicorp/precise64"
10+
11+
# map the root of redis-py to /home/vagrant/redis-py
12+
config.vm.synced_folder "../", "/home/vagrant/redis-py"
13+
14+
# install the redis server
15+
config.vm.provision :shell, :path => "bootstrap.sh"
16+
config.vm.provision :shell, :path => "install_redis.sh"
17+
18+
end

vagrant/bootstrap.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
# need make to build redis
4+
sudo apt-get install make

vagrant/install_redis.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
pushd /home/vagrant
4+
5+
# if there's an existing redis running (started at boot?) kill it
6+
if [ -a /etc/init.d/redis_master ]
7+
then
8+
sudo /etc/init.d/redis_master stop
9+
sudo update-rc.d -f redis_master remove
10+
sudo rm -f /etc/init.d/redis_master
11+
fi
12+
13+
# delete any previous provisioned redis
14+
rm -rf /home/vagrant/redis
15+
rm -rf /home/vagrant/redis-2.8.8.tar.gz
16+
17+
# download, unpack and build redis in /home/vagrant/redis
18+
wget http://download.redis.io/releases/redis-2.8.8.tar.gz
19+
tar zxvf redis-2.8.8.tar.gz
20+
mv redis-2.8.8 /home/vagrant/redis
21+
cd /home/vagrant/redis
22+
make
23+
24+
# include our overridden config options
25+
cat /home/vagrant/redis-py/vagrant/redis-override.conf >> /home/vagrant/redis/redis.conf
26+
27+
# link to our init.d script
28+
sudo cp /home/vagrant/redis-py/vagrant/redis_init_script /etc/init.d/redis_master
29+
# and tell update-rc about it
30+
sudo update-rc.d redis_master defaults 99
31+
# and finally start it
32+
sudo /etc/init.d/redis_master start
33+
34+
popd

vagrant/redis-override.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
daemonize yes

vagrant/redis_init_script

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
#
3+
# Simple Redis init.d script conceived to work on Linux systems
4+
# as it does use of the /proc filesystem.
5+
6+
REDISPORT=6379
7+
EXEC=/home/vagrant/redis/src/redis-server
8+
CLIEXEC=/home/vagrant/redis/src/redis-cli
9+
10+
PIDFILE=/var/run/redis.pid
11+
CONF=/home/vagrant/redis/redis.conf
12+
13+
case "$1" in
14+
start)
15+
if [ -f $PIDFILE ]
16+
then
17+
echo "$PIDFILE exists, process is already running or crashed"
18+
else
19+
echo "Starting Redis server..."
20+
$EXEC $CONF
21+
fi
22+
;;
23+
stop)
24+
if [ ! -f $PIDFILE ]
25+
then
26+
echo "$PIDFILE does not exist, process is not running"
27+
else
28+
PID=$(cat $PIDFILE)
29+
echo "Stopping ..."
30+
$CLIEXEC -p $REDISPORT shutdown
31+
while [ -x /proc/${PID} ]
32+
do
33+
echo "Waiting for Redis to shutdown ..."
34+
sleep 1
35+
done
36+
echo "Redis stopped"
37+
fi
38+
;;
39+
*)
40+
echo "Please use start or stop as first argument"
41+
;;
42+
esac

0 commit comments

Comments
 (0)