Skip to content

Commit 4911536

Browse files
committed
Update entrypoint. Clean up messaging during connection.
1 parent 9e7b4b1 commit 4911536

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ADD ./package.json .
88

99
ADD ./yarn.lock .
1010

11+
ADD ./docker-entry.sh .
12+
1113
RUN yarn install
1214

1315
ADD ./public/*.* ./public/
@@ -20,6 +22,6 @@ RUN usermod -a -G mousebrainmicro mluser
2022

2123
USER mluser
2224

23-
CMD ["node", "server/pipelineClientServer.js"]
25+
CMD ["./docker-entry.sh"]
2426

2527
EXPOSE 3100

client/api/apiQueue.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export class ApiQueue {
4141
this._basePath = basePath || "";
4242
}
4343

44+
public get IsConnected(): boolean {
45+
return !this._isKilled;
46+
}
47+
4448
public start(): boolean {
4549
if (this._isKilled) {
4650
this.createQueue();

client/api/realTimeApi.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as socketIOClient from "socket.io-client";
2+
import {port} from "_debugger";
23

34
export interface IRealTimeApiDelegate {
45
onServiceConnectionStateChanged?(isConnected: boolean): void;
@@ -15,7 +16,11 @@ export class RealTimeApi {
1516
public async connect(portOffset: number = 0) {
1617
try {
1718
const loc = window.location;
18-
const url = `${loc.protocol}//${loc.hostname}:${parseInt(loc.port) + portOffset}`;
19+
20+
const port = parseInt(loc.port);
21+
const portString = isNaN(port) ? "" : `:${port + portOffset}`;
22+
23+
const url = `${loc.protocol}//${loc.hostname}${portString}`;
1924
this._socket = socketIOClient(url);
2025

2126
this._socket.on("connect", () => this.onServiceConnectionStateChanged(true));

client/components/PageLayout.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ interface IPageLayoutState {
6565
buildVersion?: number;
6666
loadedBuildVersion?: number;
6767
processId?: number;
68-
isServerConnected?: boolean;
68+
isInternalApiConnected?: boolean;
69+
isSocketIoServerConnected?: boolean;
6970
isSidebarExpanded?: boolean;
7071
thumbsHostname?: string;
7172
thumbsPort?: number;
@@ -85,7 +86,8 @@ export class PageLayout extends React.Component<IPageLayoutProps, IPageLayoutSta
8586
buildVersion: null,
8687
loadedBuildVersion: null,
8788
processId: null,
88-
isServerConnected: false,
89+
isInternalApiConnected: false,
90+
isSocketIoServerConnected: false,
8991
isSidebarExpanded: !PreferencesManager.Instance.IsSidebarCollapsed,
9092
thumbsHostname: "",
9193
thumbsPort: 80,
@@ -114,12 +116,17 @@ export class PageLayout extends React.Component<IPageLayoutProps, IPageLayoutSta
114116
}
115117

116118
public render() {
117-
if (!this.state.isServerConnected) {
119+
if (!this.state.isInternalApiConnected) {
118120
return (
119-
<Message warning style={{margin: "20px"}}>The server is no longer responding. The service may be down.
121+
<Message warning style={{margin: "20px"}}>The server is not responding. The service may be down.
120122
Will continue to retry the connection.</Message>);
121123
}
122124

125+
if (!this.state.isSocketIoServerConnected) {
126+
return (
127+
<Message style={{margin: "20px"}}>Establishing connection...</Message>);
128+
}
129+
123130
const width = this.state.isSidebarExpanded ? 199 : 79;
124131
const icon = this.state.isSidebarExpanded ? "labeled" : true;
125132

@@ -221,10 +228,10 @@ export class PageLayout extends React.Component<IPageLayoutProps, IPageLayoutSta
221228
public onServiceConnectionStateChanged(isConnected: boolean) {
222229
if (isConnected) {
223230
this._internalApi.start();
224-
this.setState({isServerConnected: true});
231+
this.setState({isSocketIoServerConnected: true});
225232
} else {
226233
this._internalApi.kill();
227-
this.setState({isServerConnected: false});
234+
this.setState({isSocketIoServerConnected: false, isInternalApiConnected: false});
228235
}
229236
}
230237

@@ -245,6 +252,8 @@ export class PageLayout extends React.Component<IPageLayoutProps, IPageLayoutSta
245252
this.setState({loadedBuildVersion: message.buildVersion});
246253
}
247254

255+
this.setState({isInternalApiConnected: true});
256+
248257
this._realTimeApi.connect(message.socketIoPortOffset).then();
249258
}
250259

server/pipelineClientServer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function startSocketIOServer(server = null) {
8383
const io = require("socket.io")(server);
8484

8585
io.on("connection", (socket) => {
86+
debug("socket.io connection");
8687
socket.on("stopMicroscopeAcquisition", () => {
8788
});
8889
socket.on("restartHubProxy", () => {

0 commit comments

Comments
 (0)