|
2 | 2 |
|
3 | 3 | ## About the project |
4 | 4 |
|
5 | | -Sets up an API with data from [Serviceplatformen Organisation](https://digitaliseringskataloget.dk/integration/sf1500). |
| 5 | +Sets up an API with data from [Serviceplatformen Organisation][sf1500]. |
6 | 6 |
|
7 | 7 | ### Built with |
8 | 8 |
|
@@ -119,14 +119,68 @@ for help run |
119 | 119 | docker compose exec phpfpm bin/console organisation:fetch:data --help |
120 | 120 | ``` |
121 | 121 |
|
122 | | -**To avoid issues with memory leaks during development add the |
123 | | -`--no-debug` flag to the fetch data command.** You may also want to |
| 122 | +__To avoid issues with memory leaks during development add the |
| 123 | +`--no-debug` flag to the fetch data command.__ You may also want to |
124 | 124 | add the verbose flag to see progress. |
125 | 125 |
|
126 | 126 | ```sh |
127 | 127 | docker compose exec phpfpm bin/console --no-debug organisation:fetch:data -vvv |
128 | 128 | ``` |
129 | 129 |
|
| 130 | +## Multi-database setup |
| 131 | + |
| 132 | +Fetching all data from [SF1500] can be unstable, so for production we use a multi-database setup; one database is |
| 133 | +*current* and the other is used to fetch data. If all data is successfully fetched into ‘the other“ database, it will |
| 134 | +become ‘the current“ database. |
| 135 | + |
| 136 | +Data is fetched by running `bin/fetch-data`, but first a little configuration must be made: |
| 137 | + |
| 138 | +```sh |
| 139 | +# Copy the example config |
| 140 | +cp bin/fetch-data.config.example bin/fetch-data.config |
| 141 | +``` |
| 142 | + |
| 143 | +Edit `bin/fetch-data.config` to match your; the most important (and only required) config variable is `database_urls`. |
| 144 | + |
| 145 | +When the configuration is in place, run |
| 146 | + |
| 147 | +``` sh |
| 148 | +bin/fetch-data |
| 149 | +``` |
| 150 | + |
| 151 | +to fetch all data into the first database, i.e. the first entry in `database_urls`. If the command succeeds, the first |
| 152 | +database will become the current database. If you run the command again, data will be fetched into the second database, |
| 153 | +and if the fetching succeeds, the second database will become the current database. |
| 154 | + |
| 155 | +For testing that the switching of databases actually work, set |
| 156 | + |
| 157 | +```sh |
| 158 | +# bin/fetch-data.config |
| 159 | +max=10 |
| 160 | +``` |
| 161 | + |
| 162 | +in `bin/fetch-data.config` to fetch at most 10 items of each type. |
| 163 | + |
| 164 | +To test that switching databases does not accur in case of an error during fetching, you can define a bogus database URL |
| 165 | +before running `bin/fetch-data`: |
| 166 | + |
| 167 | +```sh |
| 168 | +# bin/fetch-data.config |
| 169 | +database_urls=( |
| 170 | + 'mysql://db:[email protected]:3306/db' |
| 171 | +) |
| 172 | +``` |
| 173 | + |
| 174 | +If nedd be, you can define which [compose command](https://docs.docker.com/compose/compose-application-model/#cli) (the |
| 175 | +default being `docker compose`) is actually used to run the compose setup: |
| 176 | + |
| 177 | +```sh |
| 178 | +# bin/fetch-data.config |
| 179 | +compose=my-custom-compose |
| 180 | +``` |
| 181 | + |
| 182 | +See [`bin/fetch-data.config.example`](bin/fetch-data.config.example) for details on configuration variables. |
| 183 | + |
130 | 184 | ## API |
131 | 185 |
|
132 | 186 | See |
@@ -209,8 +263,8 @@ we decided to adhere to in this project. |
209 | 263 | * Markdown files (markdownlint standard rules) |
210 | 264 |
|
211 | 265 | ```sh |
212 | | - docker compose run --rm node yarn install |
213 | | - docker compose run --rm node yarn coding-standards-check |
| 266 | + docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore LICENSE.md --ignore vendor/ '**/*.md' --fix |
| 267 | + docker run --rm --volume "$PWD:/md" peterdavehello/markdownlint markdownlint --ignore LICENSE.md --ignore vendor/ '**/*.md' |
214 | 268 | ``` |
215 | 269 |
|
216 | 270 | * Shell scripts |
@@ -244,3 +298,5 @@ psalm |
244 | 298 | ```sh |
245 | 299 | docker compose exec phpfpm composer code-analysis |
246 | 300 | ``` |
| 301 | + |
| 302 | +[sf1500]: https://digitaliseringskataloget.dk/integration/sf1500 |
0 commit comments