Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

need to commit/push more often

  • Loading branch information...
commit 7ecb77ad7ceaf2391805ef7b25af6b3aea6c99d3 1 parent 455b533
Jurg van Vliet authored April 16, 2012
4  decommission.py
@@ -69,8 +69,8 @@ def log(message, logging='warning'):
69 69
 	log('remove redis.conf', 'info')
70 70
 	os.system("/bin/rm -f /etc/redis/redis.conf")
71 71
 	# and empty the cron as well
72  
-	log('empty the cron', 'info')
73  
-	os.system("/bin/echo | /usr/bin/crontab")
  72
+	#log('empty the cron', 'info')
  73
+	#os.system("/bin/echo | /usr/bin/crontab")
74 74
 
75 75
 	# make sure we make a clean AMI, with all monit checks monitored
76 76
 	log("finally, monitor all (monit), but 'redis' and slave", 'info')
1  monitor.py
@@ -251,6 +251,7 @@ def put(self):
251 251
 		if monitoring in ['on', 'all']:
252 252
 			# first get all we need
253 253
 			[names, values, units, dimensions] = self.collect(monitoring)
  254
+			print [names, values, units, dimensions]
254 255
 			while len(names) > 0:
255 256
 				names20 = names[:20]
256 257
 				values20 = values[:20]
15  prepare.py
@@ -57,7 +57,7 @@ def log(message, logging='warning'):
57 57
 # we are going to work with local files, we need our path
58 58
 path = os.path.dirname(os.path.abspath(__file__))
59 59
 
60  
-def provision(key, access, cluster, size, maxmemory = -1, persistence="no", snapshot=None, rdb=None):
  60
+def provision(key, access, cluster, size, maxmemory=-1, policy=None, persistence="no", snapshot=None, rdb=None):
61 61
 	log('start provisioning', 'info')
62 62
 	# ec2 is region specific
63 63
 	region_info = RegionInfo(name=region,
@@ -130,6 +130,9 @@ def prepare():
130 130
 		if maxmemory > 0:
131 131
 			os.system("/bin/sed 's/^# maxmemory <bytes>.*$/maxmemory {0}/' -i {1}".format(maxmemory, dst))
132 132
 
  133
+			if policy != None:
  134
+				os.system("/bin/sed 's/^# maxmemory-policy.*$/maxmemory-policy {0}/' -i {1}".format(policy, dst))
  135
+
133 136
 		# and root's cron will be set accordingly as well
134 137
 		log('setting up cron', 'info')
135 138
 		os.system("/bin/sed 's:INSTALLPATH:{0}:' {1} | /usr/bin/crontab".format(path, cron))
@@ -200,9 +203,15 @@ def meminfo():
200 203
 		rdb = None
201 204
 
202 205
 	maxmemory = -1
  206
+	policy = None
203 207
 	try:
204 208
 		if userdata['maxmemory'] == 'on':
205 209
 			maxmemory = int(0.6 * (meminfo()['MemTotal'] * 1024))
  210
+
  211
+		try:
  212
+			policy = userdata['maxmemory-policy']
  213
+		except:
  214
+			pass
206 215
 	except:
207 216
 		pass
208 217
 
@@ -211,5 +220,5 @@ def meminfo():
211 220
 	# Usefult for playing around with this project
212 221
 	size = 5 if size == 0 else size	
213 222
 
214  
-	provision(sys.argv[1], sys.argv[2], cluster, size, maxmemory,
215  
-				persistence=persistence, snapshot=snapshot, rdb=rdb)
  223
+	provision(sys.argv[1], sys.argv[2], cluster, size, maxmemory, policy,
  224
+					persistence=persistence, snapshot=snapshot, rdb=rdb)
8  remaster.py
@@ -66,12 +66,16 @@ def log(message, logging='info'):
66 66
 		if link_status != "up":
67 67
 			log('how long are we down?', 'info')
68 68
 			link_down_since_seconds = info['master_link_down_since_seconds']
  69
+			master_sync_in_progress = info['master_sync_in_progress']
69 70
 
70  
-			down = (link_down_since_seconds > 30)
  71
+			# if not syncing, and link down longer than 30s
  72
+			down = ((master_sync_in_progress == 0) and
  73
+					(link_down_since_seconds > 30))
71 74
 		else:
72 75
 			down = False
  76
+
73 77
 	except Exception as e:
74  
-		log('we are down, or we were master, in case we should not be here ', 'info')
  78
+		log('master are down, or we were master, in any case we should not be here ', 'info')
75 79
 		down = True
76 80
 
77 81
 	if down:

0 notes on commit 7ecb77a

Please sign in to comment.
Something went wrong with that request. Please try again.