Skip to content

Commit

Permalink
Update readme about configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kairoh committed Apr 3, 2022
1 parent 5782c6d commit 89abd95
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 16 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ USAGE

### Prerequisite

* Java JDK 11+
* Java JRE 11+
* On Windows, this application requires the _libusb_ driver to be installed. The easiest way to achieve this is to have
the official Luniistore\* software installed (but not running).

Expand All @@ -41,6 +41,46 @@ platform. You may need to make them executable first.

Note: avoid running the script as superuser/administrator, as this may create permissions issues.

### Configuration

Configuration order is :
1. (if defined) Java System property (ie: `-Dstudio.port=8081` )
2. (if defined) environment variable (ie: `STUDIO_PORT=8081` )
3. default value (inside code)

| Environment variable | Java System property | Default value | Description |
| ------------------------ | -------------------- | ------ | ----------- |
| `STUDIO_HOST` | `studio.host` | `localhost` | HTTP listen address |
| `STUDIO_PORT` | `studio.port` | `8080` | HTTP listen port |
| `STUDIO_DB_OFFICIAL` | `studio.db.official` | `~/.studio/db/official.json` | Official json file database |
| `STUDIO_DB_UNOFFICIAL` | `studio.db.unofficial` | `~/.studio/db/unofficial.json` | Unofficial json file database |
| `STUDIO_LIBRARY` | `studio.library` | `~/.studio/library/` | Library path |
| `STUDIO_TMPDIR` | `studio.tmpdir` | `~/.studio/tmp/` | Temporary path |
| `STUDIO_OPEN_BROWSER` | `studio.open.browser` | `true` | Auto open browser |
| `STUDIO_DEV_MODE` | `studio.dev.mode` | `prod` | if `dev`, enable mock mode |
| `STUDIO_MOCK_DEVICE` | `studio.mock.device` | `~/.studio/device/` | Mock device path |

Sample to disable browser launching (with env var) and listen on port 8081 (with system property) :
- On Windows
```
set STUDIO_OPEN_BROWSER=false
java -Dstudio.port=8081 \
-Dfile.encoding=UTF-8 -Dvertx.disableDnsResolver=true \
-cp $STUDIO_PATH/${project.build.finalName}.jar:$STUDIO_PATH/lib/*:. \
io.vertx.core.Launcher run ${vertx.main.verticle}
```

- On Linux / MacOS
```
export STUDIO_OPEN_BROWSER=false
java -Dstudio.port=8081 \
-Dfile.encoding=UTF-8 -Dvertx.disableDnsResolver=true \
-cp $STUDIO_PATH/${project.build.finalName}.jar:$STUDIO_PATH/lib/*:. \
io.vertx.core.Launcher run ${vertx.main.verticle}` |
```

### Using the application

The web UI is made of two screens:
Expand Down Expand Up @@ -107,6 +147,7 @@ FOR DEVELOPERS

### Prerequisite

* Java JDK 11+
* Maven 3+

### Building the application
Expand Down
43 changes: 42 additions & 1 deletion README_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UTILISATION

### Prérequis

* Java JDK 11+
* Java JRE 11+
* Sur Windows, cette application nécessite que le pilote _libusb_ soit installé. Le moyen le plus simple pour cela est
d'installer le logiciel officiel Luniistore\* (mais il ne doit pas être exécuté en même temps que STUdio).

Expand All @@ -42,6 +42,46 @@ l'interface web.

Note: Évitez d'exécuter le script en tant que superutilisateur/administrateur, ce qui pourrait créer des problèmes de permissions.

### Configuration

L'ordre de configuration est le suivant
1. (si présente) variable système Java (ex: `-Dstudio.port=8081` )
2. (si présente) variable d'environnement (ex: `STUDIO_PORT=8081` )
3. valeur par défaut (dans le code)

| Variable d'environnement | Variable système Java | Défaut | Description |
| ------------------------ | -------------------- | ------ | ----------- |
| `STUDIO_HOST` | `studio.host` | `localhost` | Adresse d'écoute HTTP |
| `STUDIO_PORT` | `studio.port` | `8080` | Port d'écoute HTTP |
| `STUDIO_DB_OFFICIAL` | `studio.db.official` | `~/.studio/db/official.json` | Fichier BDD json officiel |
| `STUDIO_DB_UNOFFICIAL` | `studio.db.unofficial` | `~/.studio/db/unofficial.json` | Fichier BDD json non-officiel |
| `STUDIO_LIBRARY` | `studio.library` | `~/.studio/library/` | Répertoire de la bibliothèque |
| `STUDIO_TMPDIR` | `studio.tmpdir` | `~/.studio/tmp/` | Répertoire temporaire |
| `STUDIO_OPEN_BROWSER` | `studio.open.browser` | `true` | Ouverture auto du navigateur |
| `STUDIO_DEV_MODE` | `studio.dev.mode` | `prod` | Si `dev`, active le mode bouchon |
| `STUDIO_MOCK_DEVICE` | `studio.mock.device` | `~/.studio/device/` | Répertoire de l'appareil bouchon |

Ex pour ne pas lancer de navigateur (via la variable d'environnement) et écouter sur le port 8081 (via la variable systeme) :
- sous Windows
```
set STUDIO_OPEN_BROWSER=false
java -Dstudio.port=8081 \
-Dfile.encoding=UTF-8 -Dvertx.disableDnsResolver=true \
-cp $STUDIO_PATH/${project.build.finalName}.jar:$STUDIO_PATH/lib/*:. \
io.vertx.core.Launcher run ${vertx.main.verticle}
```

- sous Linux / MacOS
```
export STUDIO_OPEN_BROWSER=false
java -Dstudio.port=8081 \
-Dfile.encoding=UTF-8 -Dvertx.disableDnsResolver=true \
-cp $STUDIO_PATH/${project.build.finalName}.jar:$STUDIO_PATH/lib/*:. \
io.vertx.core.Launcher run ${vertx.main.verticle}` |
```

### Utiliser l'application

L'interface web est composée de deux écrans :
Expand Down Expand Up @@ -110,6 +150,7 @@ POUR LES DÉVELOPPEURS

### Prérequis

* Java JDK 11+
* Maven 3+

### Building the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ private void writeStoryJson(StoryPack pack, JsonWriter writer, TreeMap<String, b
// Write (optional) enriched pack metadata
if (pack.getEnriched() != null) {
String packTitle = pack.getEnriched().getTitle();
if (packTitle != null) {
writer.name("title").value(packTitle);
} else {
writer.name("title").value("MISSING_PACK_TITLE");
}
writer.name("title").value(packTitle != null ? packTitle : "MISSING_PACK_TITLE");
if (pack.getEnriched().getDescription() != null) {
writer.name("description").value(pack.getEnriched().getDescription());
}
Expand All @@ -87,14 +83,12 @@ private void writeStoryJson(StoryPack pack, JsonWriter writer, TreeMap<String, b
StageNode node = pack.getStageNodes().get(i);
writer.beginObject();
writer.name("uuid").value(node.getUuid());

// Write (optional) enriched node metadata
if (node.getEnriched() != null) {
writeEnrichedNodeMetadata(writer, node);
}

// The first stage node is marked as such
if (i == 0) {
// The first stage node is marked as such
writer.name("squareOne").value(true);
}
writer.name("image");
Expand Down Expand Up @@ -181,11 +175,7 @@ private void writeStoryJson(StoryPack pack, JsonWriter writer, TreeMap<String, b

private void writeEnrichedNodeMetadata(JsonWriter writer, Node node) throws IOException {
String nodeName = node.getEnriched().getName();
if (nodeName != null) {
writer.name("name").value(nodeName);
} else {
writer.name("name").value("MISSING_NAME");
}
writer.name("name").value(nodeName != null ? nodeName : "MISSING_NAME");
EnrichedNodeType nodeType = node.getEnriched().getType();
if (nodeType != null) {
writer.name("type").value(nodeType.label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private CompletionStage<List<RawStoryPackInfos>> readPackIndex(DeviceHandle hand
long uuidLowBytes = sdPackSectors.getLong(LibUsbMassStorageHelper.SECTOR_SIZE + 8);
UUID uuid = new UUID(uuidHighBytes, uuidLowBytes);
LOGGER.debug("Pack UUID: {}", uuid);
RawStoryPackInfos spInfos = new RawStoryPackInfos(); //uuid, version, startSector, sizeInSectors, statsOffset, samplingRate);
RawStoryPackInfos spInfos = new RawStoryPackInfos();
spInfos.setUuid(uuid);
spInfos.setVersion(version);
spInfos.setStartSector(startSector);
Expand Down
3 changes: 3 additions & 0 deletions metadata/src/test/java/studio/config/StudioConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void getValue() throws Exception {
System.setProperty(sc.getPropertyName(), exp3);
String act3 = sc.getValue();
assertEquals(exp3, act3, "bad system value");
// both sys and env : sys wins
String actBoth = withEnvironmentVariable(sc.name(), exp2).execute(() -> sc.getValue());
assertEquals(exp3, actBoth, "sys should override env");
});
}

Expand Down

0 comments on commit 89abd95

Please sign in to comment.