Autoreload of rules and scripts in Cyphesis
I’ve done some work in Cyphesis to allow for much more powerful features for live editing of the world, mainly editing rules and scripts.
Cyphesis have since long before had support for live editing of rules. It has been possible to send Atlas operations from clients for editing or installing new rules.
However, this is not really the workflow you would want, since any rule change would be detached from the source code.
Instead you want a workflow where rules are stored in the source tree, using Git, and then updated in the running server when they are installed into the server installation location.
To achieve this I’ve worked on these areas:
- Rules are no longer stored in the database (which used to be PostgreSQL, but now is SQLite). Only accounts and entities are stored in the database. The rules are instead stored on disk, as Atlas files (xml).
- The Cyphesis server process will observe all file changes in the rules directory, and automatically reload any changed files.
- The server will also observe all file changes for the Python scripts directory, and reload any Python scripts that changes.
This setup works nicely with CMake, since it will by default only install files that have changed.
The workflow is now instead
- Make edits in the Cyphesis source directory for the rule or script you want to change.
- Execute “make install” which will CMake copy only the changed files into the Cyphesis installation location.
- Have Cyphesis automatically pick up on the change and reload or add the changes.
Having tried this workflow I can say that it’s a huge improvement compared to the previous one. It’s now much more easier add or alter entity types and alter their behaviour.