Browse Source

LodelContext is used in the lodelsite starting process

Roland Haroutiounian 8 years ago
parent
commit
360a60fee7
2 changed files with 20 additions and 1 deletions
  1. 10
    1
      lodel/context.py
  2. 10
    0
      progs/slim/slim.py

+ 10
- 1
lodel/context.py View File

@@ -271,4 +271,13 @@ initialize it anymore")
271 271
             warnings.warn("A module exposure leads in globals overwriting for \
272 272
 key '%s'" % alias)
273 273
         globs[alias] = obj
274
-        
274
+
275
+    ## @brief initializes a context from the path
276
+    # @param path str
277
+    @classmethod
278
+    def from_path(cls, path):
279
+        sitename = path.split('/')[-1]
280
+        if cls._type == cls.MULTISITE:
281
+            cls._contexts[sitename] = cls.new(sitename)
282
+        else:
283
+            cls._current = cls.new(sitename)

+ 10
- 0
progs/slim/slim.py View File

@@ -253,6 +253,15 @@ def get_pid(name):
253 253
 ##@brief Start an instance
254 254
 #@param names list : instance name list
255 255
 def start_instances(names, foreground):
256
+    from lodel.context import LodelContext
257
+    for name in names:
258
+        if name in LodelContext._contexts:
259
+            logging.warning("The instance %s is already activated" % name)
260
+            continue
261
+        LodelContext.from_path(name)
262
+        logging.info("Instance '%s' started.")
263
+
264
+    '''
256 265
     pids = get_pids()
257 266
     store_datas = get_store_datas()
258 267
     
@@ -274,6 +283,7 @@ def start_instances(names, foreground):
274 283
             pids[name] = curexec.pid
275 284
             logging.info("Instance '%s' started. PID %d" % (name, curexec.pid))
276 285
     save_pids(pids)
286
+    '''
277 287
 
278 288
 ##@brief Stop an instance given its name
279 289
 #@param names list : names list

Loading…
Cancel
Save