-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy-redis.reb
51 lines (36 loc) · 1.24 KB
/
deploy-redis.reb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
REBOL[
Title: "Deploy Redis server"
Author: "Boleslav Brezovsky"
Date: 21-1-2014
Notes: {
This script executes instrictions from [this page](http://redis.io/topics/quickstart)
It expects that you already have redis-server in /usr/local/bin/
It needs file %redis_init_script in same directory
}
Requirements: [
%redis_init_script
%redis.conf
]
]
; read command line arguments
args: system/options/args
port: args/1
; make redis conf dirs
mkdir %/etc/redis
mkdir %/var/redis
; customize and copy init script - replace default port number
init-script: read %redis_init_script
replace init-script "6379" port
write join %/etc/init.d/redis_ port init-script
; customize and copy configuration file
config: read %redis.conf
replace config "daemonize no" "daemonize yes"
replace config "pidfile /var/run/redis.pid" rejoin ["pidfile /var/run/redis" port ".pid"]
replace config "port 6379" join "port " port
replace config {logfile ""} rejoin ["/var/log/redis_" port ".log"]
replace config "dir ./" join "dir /var/redis/" port
write rejoin [ %/etc/redis/ port %.conf ] config
; add redis init script to defualt runlevels
call rejoin ["update-rc.d redis_" port " defaults"]
; run redis instance
call rejoin ["/etc/init.d/redis_" port " start"]