Skip to content

Commit ffe3843

Browse files
committed
Use Kyron examples from module itself
1 parent 58f8409 commit ffe3843

File tree

11 files changed

+103
-92
lines changed

11 files changed

+103
-92
lines changed

images/qnx_x86_64/build/init.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,7 @@ libslog2.so.1 # System logging library (slog2_* functions)
9595
devb-eide # Block device driver for IDE/SATA hard drives and SSDs
9696
# Required for mounting QNX6 file systems from disk partitions
9797

98+
# Orchestrator example needed
99+
[type=link] /data=/tmp_ram
98100

99101
[+include] ${MAIN_BUILD_FILE_DIR}/system.build # Include additional system build configurations

showcases/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ score_pkg_bundle(
1616
name = "showcases_all",
1717
bins = ["//showcases/cli" ],
1818
other_package_files = [
19-
"//showcases/standalone:comm_pkg_files",
20-
"//showcases/kyron:kyron_pkg_files",
19+
"//showcases/standalone:comm_pkg_files",
20+
"//showcases/standalone:kyron_pkg_files",
2121
"//showcases/orchestration_persistency:orch_per_pkg_files",
2222
"//showcases/simple_lifecycle:simple_lifecycle_pkg_files",
2323
],

showcases/cli/README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,45 @@ To make this work each example shall deploy configuration file `name.score.json`
2222
"env": {
2323
// env to be used when running
2424
},
25-
"delay": "number" // Optional delay between two consecutive apps
25+
"delay": "number" // Optional delay between two consecutive apps
2626
},
2727
{
2828
// ...
2929
}
3030
]
3131

3232
}
33+
```
3334

3435
Each example can run multiple executables, providing additional `apps` configs. This will be started one after another but not blocking each-other.
3536

37+
Alternatively, the configuration file can contain a top-level array of configs, allowing multiple examples to be defined in a single file:
38+
39+
```json
40+
[
41+
{
42+
"name": "First example",
43+
"description": "Description of first example",
44+
"apps": [
45+
{
46+
"path": "exec_path",
47+
"args": [],
48+
"env": {}
49+
}
50+
]
51+
},
52+
{
53+
"name": "Second example",
54+
"description": "Description of second example",
55+
"apps": [
56+
{
57+
"path": "exec_path",
58+
"args": [],
59+
"env": {}
60+
}
61+
]
62+
}
63+
]
3664
```
3765

3866
You can customize where to look for examples using env `SCORE_CLI_INIT_DIR`.

showcases/cli/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,17 @@ fn visit_dir(dir: &Path, configs: &mut Vec<ScoreConfig>) -> Result<()> {
111111
if is_score_file(&path) {
112112
let content = fs::read_to_string(&path)
113113
.with_context(|| format!("Failed reading {:?}", path))?;
114-
let config: ScoreConfig = serde_json::from_str(&content)
114+
let value: serde_json::Value = serde_json::from_str(&content)
115115
.with_context(|| format!("Invalid JSON in {:?}", path))?;
116-
configs.push(config);
116+
if value.is_array() {
117+
let found: Vec<ScoreConfig> = serde_json::from_value(value)
118+
.with_context(|| format!("Invalid JSON array in {:?}", path))?;
119+
configs.extend(found);
120+
} else {
121+
let config: ScoreConfig = serde_json::from_value(value)
122+
.with_context(|| format!("Invalid JSON in {:?}", path))?;
123+
configs.push(config);
124+
}
117125
}
118126
}
119127
Ok(())

showcases/kyron/BUILD

Lines changed: 0 additions & 22 deletions
This file was deleted.

showcases/kyron/kyron.score.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

showcases/kyron/main.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

showcases/orchestration_persistency/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn on_shutdown() -> InvokeResult {
6262
// Configure backend with directory path (workaround: KvsBuilder::dir() not available in Rust)
6363
// change back to dir, if https://github.com/eclipse-score/persistency/issues/222 is resolved.
6464
let backend = JsonBackendBuilder::new()
65-
.working_dir(PathBuf::from("./"))
65+
.working_dir(PathBuf::from("/tmp"))
6666
.build();
6767

6868
let builder = KvsBuilder::new(instance_id)
@@ -75,6 +75,19 @@ async fn on_shutdown() -> InvokeResult {
7575

7676
kvs.flush().unwrap();
7777

78+
let instance_id = kvs.parameters().instance_id;
79+
let snapshot_id = SnapshotId(0);
80+
match kvs.parameters().backend.as_any().downcast_ref(){
81+
Some(backend ) => {
82+
let backend = backend as &JsonBackend;
83+
let filename = backend.kvs_file_path(instance_id, snapshot_id);
84+
info!("KVS snapshot saved to file: {:?}", filename);
85+
},
86+
None => {
87+
88+
},
89+
};
90+
7891
Ok(())
7992
}
8093

showcases/orchestration_persistency/orch_per.score.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Orchestration persistency - Kyron example",
2+
"name": "Orchestration persistency example",
33
"description": "Example for running orchestration graph with Kyron runtime and saving the state to disk",
44
"apps":[
55
{

showcases/standalone/BUILD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ score_pkg_bundle(
1212
"//showcases/standalone:com.score.json",
1313
],
1414
)
15+
16+
score_pkg_bundle(
17+
name = "kyron",
18+
package_dir = "standalone",
19+
bins = ["@score_kyron//src/kyron:select", "@score_kyron//src/kyron:safety_task", "@score_kyron//src/kyron:main_macro"], # TODO: kyron shall have public examples in examples folder
20+
21+
config_data = [
22+
"//showcases/standalone:kyron.score.json",
23+
],
24+
)

0 commit comments

Comments
 (0)