Skip to content
Frank Rosner edited this page Nov 10, 2016 · 15 revisions

Instance Persistence

Broccoli is persisting the instances you create. You can select the desired storage back-end depending on your needs. Currently, there are two storage back-ends supported: fs and couchdb.

You can select which one you like by setting broccoli.instances.storage.type to either fs or couchdb. Please keep in mind that both might need additional configuration.

File System Storage fs

If you want to try Broccoli or run it as a single process for development purposes, you can start with the file system based storage. It requires you to specify a directory where it can store instances as JSON files through broccoli.instances.storage.url.

On startup, Broccoli will lock this folder (by creating a .lock file inside) because the file system back-end does not support concurrent access on these files. In case your Broccoli terminated irregularly you might need to check that you have no other Broccoli accessing this folder and delete the .lock file manually before restarting. Watch the logs if any data got corrupted or all instances could be loaded correctly.

Default Configuration

broccoli.instances.storage.type=fs
broccoli.instances.storage.url=instances

CouchDB Storage couchdb

For a production setup it is recommended to use the CouchDB back-end. CouchDB uses optimistic locking so you can actually have multiple Broccoli instances for load balancing or security reasons. Also it is guaranteed that you don't end up with corrupted data if Broccoli dies in the middle of a transaction.

On startup, Broccoli will check whether the specified database (specified through broccoli.instances.storage.url) is reachable. If it does not exist it will attempt to create it.

Default Configuration

broccoli.instances.storage.type=couchdb
broccoli.instances.storage.url=http://localhost:5984/broccoli_instances

Job and Service Status

Job and service status are obtained periodically from Nomad and Consul. They are cached in-memory inbetween updates and are not persisted. If Nomad or Consul are not reachable, the state will also not be available on Broccoli as soon as the cache gets invalidated.

You can control the time between two requests for job and service status by setting broccoli.polling.frequency (in seconds).

Migrating Instances

When you want to migrate instances from one Broccoli to another you have two options.

  1. You migrate the storage (e.g. duplicate the CouchDB database or copy the folder of the file system storage).
  2. You start both Broccoli instances and use the broccoli2broccoli.js script. Note that this will not preserve instances referencing outdated templates but will attempt to create them with the current version of the templates.

Using an Instance Prefix

If you want to limit actions on instances (CRUD) to a specific set matching a prefix, you can configure broccoli.instances.prefix. This is useful when having multiple Broccolis for different groups of people as Broccoli is not really multi-tenant at the moment.

Clone this wiki locally