Exhibition-RestServer: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
Zeile 74: | Zeile 74: | ||
The rest_server must be installed on a backend server. During development that can be localhost. | The rest_server must be installed on a backend server. During development that can be localhost. | ||
== Preparation == | == Preparation == | ||
<source lang="bash">tools/PackRestServer | |||
</source> | |||
* The script creates two files: InstallRestServer and rest_server.tgz | |||
* Put that to the '''backend server''', e.g. into the /tmp directory | |||
<source lang="bash">cd /tmp | |||
./InstallRestServer | |||
</source> | |||
* Note: $PROJECT is the name of the project | |||
* The script creates the directories /usr/share/$PROJECT and /etc/$PROJECT | |||
* Adapt the configuration in /etc/$PROJECT | |||
* Than restart the service | |||
<source lang="bash"> | |||
PROJECT=exhibition | |||
systemctl restart $PROJECT | |||
</source> |
Aktuelle Version vom 17. August 2021, 05:24 Uhr
Links[Bearbeiten]
Introduction[Bearbeiten]
The rest_server is a sub project of the dev-app implementing a backend for managing the data storage in a MySql database.
Features[Bearbeiten]
- The communication between the dev-app (as a client) and rest_server is done via HTTP in the REpresentational State Transfer design pattern.
- The program of the rest_server is a static piece of software written in Dart, the customizing is done with configuration in some files. This sub project does not have dependencies on Flutter.
- The server is a multithreaded HTTP server, the number of threads (Dart isolates) may be configured.
- The Sql statements must be specified with "named parameters". But the dart module mysqldb cannot handle named parameters. Therefore the statements will be converted into "positional parameters" automatically.
Configuration[Bearbeiten]
Main Configuration[Bearbeiten]
The main configuration is done by a yaml file:
--- # Example configuration file for the rest server. Created by rest_server. service: address: 0.0.0.0 port: 58031 dataDirectory: /tmp/unittest/data sqlDirectory: ${path.dirname(sqlFile)} threads: 1 watchDogPause: 60 # logFile: /var/log/local/exhibition.log trace: answerLength: 200 db: db: dbtest user: dbtest code: "TopSecret" host: localhost port: 3306 primaryTable: persons timeout: 30 traceDataLength: 200 clientSessionTimeout: 900
Sql Configuration[Bearbeiten]
The SQL statements for each module must be specified in a yaml file.
Note: Normally this file is generated by the meta_tool from the metadata.
--- # SQL statements of the module "Persons": module: Persons list: type: list parameters: [] sql: select * from persons; byId: type: record parameters: [ ":id" ] sql: "select * from persons where person_id=:id;" update: type: update parameters: [":id", ":name", ":email", ":changedby"] sql: "UPDATE persons SET person_name=:name, person_email=:email, person_changed=NOW(), person_changedby=:changedby WHERE person_id=:id;" insert: type: insert parameters: [":name", ":email", ":createdby"] sql: "INSERT INTO persons(person_name, person_email, person_created, person_createdby) VALUES(:name, :email, NOW(), :createdby);" delete: type: delete parameters: [':id'] sql: "DELETE FROM persons WHERE person_id=:id;"
Installation[Bearbeiten]
The rest_server must be installed on a backend server. During development that can be localhost.
Preparation[Bearbeiten]
tools/PackRestServer
- The script creates two files: InstallRestServer and rest_server.tgz
- Put that to the backend server, e.g. into the /tmp directory
cd /tmp
./InstallRestServer
- Note: $PROJECT is the name of the project
- The script creates the directories /usr/share/$PROJECT and /etc/$PROJECT
- Adapt the configuration in /etc/$PROJECT
- Than restart the service
PROJECT=exhibition
systemctl restart $PROJECT