Browse Source

Bugfix in slim + enhancement of mass_deploy

Now mass_deploy is able to stop when slim fails indicating on wich action slim fails
Bufixing webui conf edition
Yann Weber 7 years ago
parent
commit
747ff25ada
2 changed files with 18 additions and 8 deletions
  1. 14
    4
      progs/mass_deploy.sh
  2. 4
    4
      progs/slim/slim.py

+ 14
- 4
progs/mass_deploy.sh View File

@@ -19,6 +19,16 @@ usage() {
19 19
 \t\t- purgedb is to remove all created mongodb db\n"
20 20
 }
21 21
 
22
+slim_fails() {
23
+	if [ -z "$1" ]
24
+	then
25
+		echo "SLIM fails for some reason. Abording..." >&2
26
+	else
27
+		echo "SLIM fails when $1. Abording...." >&2
28
+	fi
29
+	exit 1
30
+}
31
+
22 32
 test -f $conffile || badconf
23 33
 #Load conffile
24 34
 . $conffile
@@ -111,9 +121,9 @@ echo "Creating instances"
111 121
 for i in $(seq $ninstance)
112 122
 do
113 123
 	iname="${random_name}_$(printf "%05d" $i)"
114
-	slim -n $iname -c
115
-	slim -n $iname -s --interface web --static-url 'http://127.0.0.1/static' --uwsgi-workers 2
116
-	slim -n $iname -m
124
+	slim -n $iname -c || slim_fails "creating instance"
125
+	slim -n $iname -s --interface web --static-url 'http://127.0.0.1/static' --uwsgi-workers 2 || slim_fails "configuring instancee"
126
+	slim -n $iname -m || slim_fails "running make in instance"
117 127
 
118 128
 	#Mongo db database creation
119 129
 	dbname="${MONGODB_DB_PREFIX}_$iname"
@@ -125,7 +135,7 @@ db.addUser('$dbuser', '$dbpass', ['readWrite', '$dbname'])
125 135
 exit
126 136
 EOF
127 137
 	#Append created db to instance conf
128
-	slim -n $iname -s --datasource_connectors mongodb --host localhost --user $dbuser --password $dbpass --db_name $dbname
138
+	slim -n $iname -s --datasource_connectors mongodb --host localhost --user $dbuser --password $dbpass --db_name $dbname || slim_fails "configuring the instance's datasource"
129 139
 
130 140
 done
131 141
 

+ 4
- 4
progs/slim/slim.py View File

@@ -94,14 +94,14 @@ def set_conf(name, args):
94 94
             config['lodel2.webui']['listen_address'] = str(args.listen_address)
95 95
         if args.static_url is not None:
96 96
             config['lodel2.webui']['static_url'] = str(args.static_url)
97
+        if args.uwsgi_workers is not None:
98
+            config['lodel2.webui']['uwsgi_workers'] = str(args.uwsgi_workers)
97 99
     else: #interface is python
98 100
         if args.listen_port is not None or args.listen_address is not None:
99 101
             logging.error("Listen port and listen address will not being set. \
100 102
 Selected interface is not the web iterface")
101 103
         if 'lodel.webui' in config:
102 104
             del(config['lodel2.webui'])
103
-        if args.uwsgi_workers is not None:
104
-            config['lodel2.webui']['uwsgi_workers'] = int(args.uwsgi_workers)
105 105
 
106 106
     if args.datasource_connectors is not None:
107 107
         darg = args.datasource_connectors
@@ -491,8 +491,8 @@ to 1 instance")
491 491
         help="Select the password name to connect the datasource")
492 492
     confs.add_argument('--db_name', type=str,
493 493
         help="Select the database name on which datasource will be connect")
494
-    confs.add_argument('-p', '--uwsgi-workers', type=str, default='2',
495
-                       help="Number of workers to spawn at the start of uwsgi")
494
+    confs.add_argument('--uwsgi-workers', type=int, default='2',
495
+        metavar = 'N', help="Number of workers to spawn at the start of uwsgi")
496 496
     return parser
497 497
 
498 498
 if __name__ == '__main__':

Loading…
Cancel
Save