Skip to content

Commit

Permalink
corrected fetchContainerLogs
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Feb 10, 2024
1 parent d719314 commit 45f1d94
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
4 changes: 2 additions & 2 deletions android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ public void wifiRemoveall(Promise promise) {
}

@ReactMethod
public void fetchContainerLogs(Promise promise, String containerName, String tailCount) {
public void fetchContainerLogs(String containerName, String tailCount, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "fetchContainerLogs");
try {
Expand All @@ -1500,7 +1500,7 @@ public void fetchContainerLogs(Promise promise, String containerName, String tai
Log.d("ReactNative", "result string="+resultString);
promise.resolve(resultString);
} catch (Exception e) {
Log.d("ReactNative", e.getMessage());
Log.d("ReactNative", "an error happened="+e.getMessage());
promise.reject(e);
}
});
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
36 changes: 34 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ const App = () => {
62, 91, 140, 55, 179, 10, 208, 210, 177, 111, 61, 46, 73, 148, 14, 62,
];
//const bloxPeerId = '12D3KooWDiBNebfFD4QwJ1qDZaeapKcbr72cJfHE8foooTX25Z1V'; //tower
//const bloxPeerId = '12D3KooWRTzN7HfmjoUBHokyRZuKdyohVVSGqKBMF24ZC3tGK78Q'; //laptop
const bloxPeerId = '12D3KooWQZBdE5zNUVTE2Aayajyy9cJDmK4bJwMZG52ieHt2f6nb'; //laptop2
const bloxPeerId = '12D3KooWRTzN7HfmjoUBHokyRZuKdyohVVSGqKBMF24ZC3tGK78Q'; //laptop
// const bloxPeerId = '12D3KooWQZBdE5zNUVTE2Aayajyy9cJDmK4bJwMZG52ieHt2f6nb'; //laptop2
//const bloxPeerId = '12D3KooWAN5FaAnC4d1GhAvoYxyUXdrkCGqux1NB6Pr4cZXn813E'; //test aws server

const bloxAddr = '/dns/delta-relay.dev.fx.land/tcp/4001/p2p/12D3KooWDtA7kecHAGEB8XYEKHBUTt8GsRfMen1yMs7V85vrpMzC/p2p-circuit/p2p/' + bloxPeerId;
Expand Down Expand Up @@ -657,6 +657,38 @@ const App = () => {
color={inprogress ? 'green' : 'blue'}
/>

<Button
title={inprogress ? 'Getting...' : 'Get Node Logs'}
onPress={async () => {
try {
if (initComplete) {
fula.checkConnection().then((r: any) => {
console.log('connection check');
console.log(r);
if (r) {
console.log(
'initialization is completed. send logs command'
);
fxblox
.fetchContainerLogs('fula_node', '30')
.then((res: any) => {
console.log('fetchContainerLogs received');
console.log(res);
})
.catch((e: any) => {
console.log('fetchContainerLogs failed');
console.log(e);
});
}
});
} else {
console.log('wait for init to complete');
}
} catch (e) {}
}}
color={inprogress ? 'green' : 'blue'}
/>

<Button
title={inprogress ? 'Getting...' : 'Reboot'}
onPress={async () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@functionland/react-native-fula",
"version": "1.44.0",
"version": "1.44.1",
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/fxblox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const fetchContainerLogs = (
let res = Fula.fetchContainerLogs(containerName, tailCount)
.then((res1) => {
try {
console.log('res1 received');
console.log(res1);
let jsonRes: BType.FetchContainerLogsResponse = JSON.parse(res1);
return jsonRes;
} catch (e) {
Expand Down

0 comments on commit 45f1d94

Please sign in to comment.