 (defn- stop-apps
   [system]
   (reduce (fn [system [app {stop-fn :stop}]]
-            (update-in system [:apps app] stop-fn))
+            (update-in system [:apps app] #(when % (stop-fn %))))
           system
           app-control-functions))
 

  ;; Memory DB configured to run in memory
  {:apps {:metadata-db (assoc (mdb-system/create-system)
                              :db (memory/create-db))
          :bootstrap (bootstrap-system/create-system)

          :indexer (indexer-system/create-system)


  (reduce (fn [system [app {start-fn :start}]]
            (update-in system [:apps app]
                       #(try
                          (when %
                            (start-fn %))
                          (catch Exception e
                            (stop-components (stop-apps system))
                            (throw e)))))
