Brain Annex : Full-Stack Data/Knowledge Management with Neo4j
HomeTech StackGuideHistoryDownload/InstallContact
Install the Neo4j Database First-Time App Deployment Routine Upgrades Start Web App

Routine Upgrades (UPDATES from changes in code base)

NOTE – this routine deployment updates ALL of : the python libraries, the web API, and the web app from the main branch of the BrainAnnex repository, which is often slightly ahead of the PyPI distribution for the various versions of the brainannex python libraries.

Stop the Web App

On LOCAL machine: simply stop Flask, if running.


On SERVER: Use PuTTY or other client (we recommend the free MobaXterm) to SSH to the server.

* Stop Gunicorn (or Flask's built-in server, whichever you're using)

if using Gunicorn (with or without Caddy):

ps -e | grep gunicorn Show all gunicorn processes
sudo pkill -f gunicorn To kill all gunicorn processes at once; it takes a bit of time
OR, if using Flask's built-in server (“Werkzeug”):
ps -e | grep flask Show all flask processes
kill 12345 Replace the number with the process ID returned by the previous command!


* Note: no need to stop the Neo4j database

Update the code base from the latest release


You may use GitHub Desktop to pull the latest version from the main branch of the repository.



sudo su - To elevate permissions to the root account
cd /home/brain_annex Or whatever location you used for your install
git reset --hard To permanently discard all local changes to all files; typically not needed, but doesn't hurt
git pull --ff-only https://github.com/BrainAnnex/brain-annex.git It fetches the remote repo, and merges it with the current one; the "--ff-only" means only update to the new history if there is no divergent local history

NOTE: your personalized "config.ini" file on the servers won't be affected, because it's NOT part of the repository. Likewise, your personalized "Caddyfile" on the server, if applicable, won't be affected
cat brainannex/__init__.py | grep __version__ Optional, to double-check the version number of your upgrade
exit To return to the normal login account (i.e., no longer root)

IF NEEDED (not always): if this upgrade involves changes in the required libraries in requirements.txt (see changelog), then one needs to perform library installs/uninstalls in venv as needed (SAFE TO DO EVEN IF NOT NEEDED!)

If you're on local machine and using an IDE such as PyCharm, you should get prompted if you change your requirements.txt file.

On Linux:

$   cd /home/brain_annex Or whatever location you used
$   source venv/bin/activate This will enter the virtual environment; notice the changed prompt in the next line
(venv) $   pip3 install -r requirements.txt It should print out "Successfully uninstalled XYZ" and "Successfully installed ABC"

To double-check (optional):
(venv) $   pip3 list Optional: to see all the installed packages
(venv) $   pip3 show SOME_PACKAGE_NAME Optional: to see more info about that particular package

To terminate operation:
(venv) $   deactivate To exit the virtual environment

IF NEEDED (usually not): if you have existing data and/or media, follow the MIGRATION PROTOCOL, if any, for the current upgrade

Check any special instructions in the Change Log, for the current release, as well as any release between the latest one and the one you're upgrading from.

Infrequently needed, but there have been cases of needed file changes and/or Cypher queries to manually run (using the Neo4j browser interface) as part of the upgrade, to migrate your existing database to the new version of the BrainAnnex web app.

Final Steps

Finally, start the Web App




Install the Neo4j Database First-Time App Deployment Routine Upgrades Start Web App