Skip to content

Commit

Permalink
Add fail callback to monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
marusak committed Sep 12, 2019
1 parent 33f2a7e commit a9e8871
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ContainerCommitModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ContainerCommitModal extends React.Component {

if (reply && 'logs' in reply && Array.isArray(reply.logs) && reply.logs.length > 0)
console.log("Container commit:", message.parameters.reply.logs.join("\n"));
}, this.props.container.isRoot)
}, this.props.onHide, this.props.container.isRoot)
.then(() => this.props.onHide())
.catch(ex => {
this.setState({
Expand Down
3 changes: 3 additions & 0 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ class Application extends React.Component {
utils.monitor("GetEvents", {},
message => {
message.parameters && message.parameters.events && this.handleEvent(message.parameters.events, root);
}, isRoot => {
this.setState({ [isRoot ? "rootServiceAvailable" : "userServiceAvailable"]: false
});
},
root
);
Expand Down
10 changes: 8 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ export function podmanAction(name, args, root) {
return varlink.call(address, "io.podman." + name, args, root);
}

export function monitor(name, args, callback, root) {
export function monitor(name, args, callback, error_callback, root) {
let address = PODMAN_ROOT_ADDRESS;
if (!root)
address = PODMAN_USER_ADDRESS;
return varlink.connect(address, root)
.then(connection => { return connection.monitor("io.podman." + name, args, callback) });
.then(connection => { return connection.monitor("io.podman." + name, args, callback) })
.catch(e => {
if (e.name === "ConnectionClosed")
error_callback(root);
else
console.log(e);
});
}

export function updateImage(id, root) {
Expand Down

0 comments on commit a9e8871

Please sign in to comment.