linny-r 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linny-r",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Executable graphical language with WYSIWYG editor for MILP models",
5
5
  "main": "server.js",
6
6
  "scripts": {
package/server.js CHANGED
@@ -160,25 +160,46 @@ const SERVER = http.createServer((req, res) => {
160
160
  }
161
161
  });
162
162
 
163
- // Start listening at the specified port number
164
- console.log('Listening at: http://127.0.0.1:' + SETTINGS.port);
165
- SERVER.listen(SETTINGS.port);
166
-
167
- // Finally, launch the GUI if this command line argument is set
168
- if(SETTINGS.launch) {
169
- console.log('Launching Linny-R in the default browser');
170
- const cmd = (PLATFORM.startsWith('win') ? 'start' : 'open');
171
- child_process.exec(cmd + ' http://127.0.0.1:' + SETTINGS.port,
172
- (error, stdout, stderr) => {
173
- if(error) {
174
- console.log('NOTICE: Failed to launch GUI in browser');
175
- console.log(error);
176
- console.log(stdout);
177
- console.log(stderr);
178
- }
179
- });
163
+ // Prepare for error on start-up.
164
+ SERVER.on('error', (err) => {
165
+ if(err.code === 'EADDRINUSE') {
166
+ success = false;
167
+ console.log('ERROR: Port', SETTINGS.port, 'is already in use.');
168
+ console.log('Some Linny-R server may be in another CLI box -- Please check.');
169
+ } else {
170
+ throw err;
171
+ }
172
+ });
173
+
174
+ // Start listening at the specified port number.
175
+ const options = {
176
+ port: SETTINGS.port,
177
+ exclusive: true
178
+ };
179
+ SERVER.listen(options, launchGUI);
180
+
181
+
182
+ function launchGUI(err) {
183
+ if(SERVER.listening) {
184
+ console.log('Listening at: http://127.0.0.1:' + SETTINGS.port);
185
+ }
186
+ // Launch the GUI if this command line argument is set.
187
+ if(SETTINGS.launch) {
188
+ console.log('Launching Linny-R in the default browser');
189
+ const cmd = (PLATFORM.startsWith('win') ? 'start' : 'open');
190
+ child_process.exec(cmd + ' http://127.0.0.1:' + SETTINGS.port,
191
+ (error, stdout, stderr) => {
192
+ if(error) {
193
+ console.log('NOTICE: Failed to launch GUI in browser');
194
+ console.log(error);
195
+ console.log(stdout);
196
+ console.log(stderr);
197
+ }
198
+ });
199
+ }
180
200
  }
181
201
 
202
+
182
203
  // Server action logging functionality
183
204
  // ===================================
184
205
  // Only actions are logged to the console as with date and time;
@@ -1155,7 +1155,8 @@ class ExperimentManager {
1155
1155
  selectedRuns(chart) {
1156
1156
  // Return list of run numbers selected in the Experiment Manager.
1157
1157
  const selx = this.selected_experiment;
1158
- if(CHART_MANAGER.runs_chart && selx && selx.charts.indexOf(chart) >= 0) {
1158
+ if(CHART_MANAGER.runs_chart && selx &&
1159
+ (selx.charts.indexOf(chart) >= 0 || CHART_MANAGER.runs_stat)) {
1159
1160
  return selx.chart_combinations;
1160
1161
  }
1161
1162
  return [];
@@ -865,7 +865,7 @@ class GUIChartManager extends ChartManager {
865
865
  }
866
866
 
867
867
  drawTable() {
868
- // Shows the statistics on the chart variables
868
+ // Shows the statistics on the chart variables.
869
869
  const html = [];
870
870
  let vbl = [];
871
871
  if(this.chart_index >= 0) vbl = MODEL.charts[this.chart_index].variables;
@@ -1002,8 +1002,8 @@ class GUIChartManager extends ChartManager {
1002
1002
  }
1003
1003
 
1004
1004
  drawChart() {
1005
- // Displays the selected chart unless an experiment is running, or already
1006
- // busy with an earlier drawChart call
1005
+ // Displays the selected chart unless an experiment is running, or
1006
+ // already busy with an earlier drawChart call.
1007
1007
  if(MODEL.running_experiment) {
1008
1008
  UI.notify(UI.NOTICE.NO_CHARTS);
1009
1009
  } else if(this.chart_index >= 0 && !this.drawing_chart) {