mirror of https://github.com/docker/docs.git
Merge pull request #1145 from kitematic/stopping-state
Add stopping state to fix immediately killing containers
This commit is contained in:
commit
8a5e2f7920
|
|
@ -13,7 +13,9 @@ class ContainerServerActions {
|
||||||
'started',
|
'started',
|
||||||
'unmuted',
|
'unmuted',
|
||||||
'updated',
|
'updated',
|
||||||
'waiting'
|
'waiting',
|
||||||
|
'kill',
|
||||||
|
'stopped'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,14 @@ var ContainerDetailsHeader = React.createClass({
|
||||||
|
|
||||||
if (this.props.container.State.Updating) {
|
if (this.props.container.State.Updating) {
|
||||||
state = <span className="status downloading">UPDATING</span>;
|
state = <span className="status downloading">UPDATING</span>;
|
||||||
} else if (this.props.container.State.Running && !this.props.container.State.Paused && !this.props.container.State.ExitCode && !this.props.container.State.Restarting) {
|
} else if (this.props.container.State.Stopping) {
|
||||||
state = <span className="status running">RUNNING</span>;
|
state = <span className="status running">STOPPING</span>;
|
||||||
} else if (this.props.container.State.Restarting) {
|
|
||||||
state = <span className="status restarting">RESTARTING</span>;
|
|
||||||
} else if (this.props.container.State.Paused) {
|
} else if (this.props.container.State.Paused) {
|
||||||
state = <span className="status paused">PAUSED</span>;
|
state = <span className="status paused">PAUSED</span>;
|
||||||
|
} else if (this.props.container.State.Restarting) {
|
||||||
|
state = <span className="status restarting">RESTARTING</span>;
|
||||||
|
} else if (this.props.container.State.Running && !this.props.container.State.ExitCode) {
|
||||||
|
state = <span className="status running">RUNNING</span>;
|
||||||
} else if (this.props.container.State.Starting) {
|
} else if (this.props.container.State.Starting) {
|
||||||
state = <span className="status running">STARTING</span>;
|
state = <span className="status running">STARTING</span>;
|
||||||
} else if (this.props.container.State.Downloading) {
|
} else if (this.props.container.State.Downloading) {
|
||||||
|
|
|
||||||
|
|
@ -13,33 +13,33 @@ var ContainerDetailsSubheader = React.createClass({
|
||||||
},
|
},
|
||||||
disableRun: function () {
|
disableRun: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return (!this.props.container.State.Running || !this.props.defaultPort || this.props.container.State.Updating);
|
return (!this.props.container.State.Running || !this.props.defaultPort || this.props.container.State.Updating);
|
||||||
},
|
},
|
||||||
disableRestart: function () {
|
disableRestart: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return (this.props.container.State.Downloading || this.props.container.State.Restarting || this.props.container.State.Updating);
|
return (this.props.container.State.Stopping || this.props.container.State.Downloading || this.props.container.State.Restarting || this.props.container.State.Updating);
|
||||||
},
|
},
|
||||||
disableStop: function () {
|
disableStop: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return (this.props.container.State.Downloading || this.props.container.State.ExitCode || !this.props.container.State.Running || this.props.container.State.Updating);
|
return (this.props.container.State.Stopping || this.props.container.State.Downloading || this.props.container.State.ExitCode || !this.props.container.State.Running || this.props.container.State.Updating);
|
||||||
},
|
},
|
||||||
disableStart: function () {
|
disableStart: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return (this.props.container.State.Downloading || this.props.container.State.Running || this.props.container.State.Updating);
|
return (this.props.container.State.Downloading || this.props.container.State.Running || this.props.container.State.Updating);
|
||||||
},
|
},
|
||||||
disableTerminal: function () {
|
disableTerminal: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return (!this.props.container.State.Running || this.props.container.State.Updating);
|
return (this.props.container.State.Stopping || !this.props.container.State.Running || this.props.container.State.Updating);
|
||||||
},
|
},
|
||||||
disableTab: function () {
|
disableTab: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,22 @@ class ContainerStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop ({name}) {
|
stopped ({id}) {
|
||||||
let containers = this.containers;
|
let containers = this.containers;
|
||||||
if (containers[name]) {
|
let container = _.find(_.values(containers), c => c.Id === id || c.Name === id);
|
||||||
containers[name].State.Running = false;
|
|
||||||
|
if (containers[container.Name]) {
|
||||||
|
containers[container.Name].State.Stopping = false;
|
||||||
|
this.setState({containers});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kill ({id}) {
|
||||||
|
let containers = this.containers;
|
||||||
|
let container = _.find(_.values(containers), c => c.Id === id || c.Name === id);
|
||||||
|
|
||||||
|
if (containers[container.Name]) {
|
||||||
|
containers[container.Name].State.Stopping = true;
|
||||||
this.setState({containers});
|
this.setState({containers});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,6 +84,10 @@ class ContainerStore {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (containers[name].State.Stopping) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_.extend(containers[name], container);
|
_.extend(containers[name], container);
|
||||||
|
|
||||||
if (containers[name].State) {
|
if (containers[name].State) {
|
||||||
|
|
@ -113,9 +129,7 @@ class ContainerStore {
|
||||||
|
|
||||||
destroyed ({id}) {
|
destroyed ({id}) {
|
||||||
let containers = this.containers;
|
let containers = this.containers;
|
||||||
let container = _.find(_.values(this.containers), container => {
|
let container = _.find(_.values(containers), c => c.Id === id || c.Name === id);
|
||||||
return container.Id === id || container.Name === id;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (container && container.State && container.State.Updating) {
|
if (container && container.State && container.State.Updating) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
restart (name) {
|
restart (name) {
|
||||||
this.client.getContainer(name).stop(stopError => {
|
this.client.getContainer(name).stop({t: 5}, stopError => {
|
||||||
if (stopError && stopError.statusCode !== 304) {
|
if (stopError && stopError.statusCode !== 304) {
|
||||||
containerServerActions.error({name, stopError});
|
containerServerActions.error({name, stopError});
|
||||||
return;
|
return;
|
||||||
|
|
@ -285,7 +285,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
stop (name) {
|
stop (name) {
|
||||||
this.client.getContainer(name).stop(error => {
|
this.client.getContainer(name).stop({t: 5}, error => {
|
||||||
if (error && error.statusCode !== 304) {
|
if (error && error.statusCode !== 304) {
|
||||||
containerServerActions.error({name, error});
|
containerServerActions.error({name, error});
|
||||||
return;
|
return;
|
||||||
|
|
@ -341,12 +341,16 @@ export default {
|
||||||
stream.on('data', json => {
|
stream.on('data', json => {
|
||||||
let data = JSON.parse(json);
|
let data = JSON.parse(json);
|
||||||
|
|
||||||
if (data.status === 'pull' || data.status === 'untag' || data.status === 'delete') {
|
if (data.status === 'pull' || data.status === 'untag' || data.status === 'delete' || data.status === 'attach') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.status === 'destroy') {
|
if (data.status === 'destroy') {
|
||||||
containerServerActions.destroyed({id: data.id});
|
containerServerActions.destroyed({id: data.id});
|
||||||
|
} else if (data.status === 'kill') {
|
||||||
|
containerServerActions.kill({id: data.id});
|
||||||
|
} else if (data.status === 'stop') {
|
||||||
|
containerServerActions.stopped({id: data.id});
|
||||||
} else if (data.id) {
|
} else if (data.id) {
|
||||||
this.fetchContainer(data.id);
|
this.fetchContainer(data.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue