LionWeb-io / lionweb-repository

Reference implementation of LionWeb repository
Apache License 2.0
2 stars 1 forks source link

Initialization of database and repositories #79

Open ftomassetti opened 4 days ago

ftomassetti commented 4 days ago

I apologize for bringing up another issue regarding initialization, but I want to ensure I fully understand the topic.

How I understand the system works now

Currently, we can start the server (e.g., by running npm run dev) and the server, based on the configuration, may create the database and repositories at startup. When doing so it would replace any existing database and/or repositories. Therefore, one should start the server once with a configuration that requests the creation of the database and repositories (setup configuration), then change the configuration to remove these options or have a second configuration file (standard configuration).

Typically, during system setup, one would start the server once with the setup configuration, manually verify that the database and repositories have been created, and then stop the server by pressing ctlr-c. Subsequently, the server would be started or restarted as needed using only the standard configuration.

Proposed changes

If I understand correctly, I am wondering if one of these two changes would be desirable and possible:

1. Conditional Creation Option

Have the possibility to specify in the configuration that we want one or two behaviors:

This would remove the need for having two configurations and even for running the server once during the setup, just to ensure the creation of the database and the repositories is done. It would be done at the first normal execution, and never again (if the proper configuration is used).

2. Command Line Flags

Alternatively one could specify a flag on the command line called --setup-only. When the flag is specified, the server would exit after creating the database and the repositories. This would remove the need to kill the server. Killing the server "after a while" may be easy for a person to do, but it could be difficult to automatize (do we just use a timeout and hope that the database and repositories creation has finished by the time the timeout expire?). So introducing this flag, would simplify the automation of the setup step.

One could also add an option called --no-setup. When specified the creation of the database and repositories would be skipped, even if specified. If we had these two flags we could avoid having two separate configurations, avoid duplications.

Do you think any of these approaches would make sense?