Prechádzať zdrojové kódy

Debug action port occupé

Loquicom 5 rokov pred
rodič
commit
608f5fc655
2 zmenil súbory, kde vykonal 47 pridanie a 18 odobranie
  1. 17 18
      node/main.js
  2. 30 0
      node/package-lock.json

+ 17 - 18
node/main.js

@@ -1,7 +1,7 @@
 #!/usr/bin/env node
 
 // Gestion du signal d'arret (SIGINT = Ctrl+C)
-process.on('SIGINT', function() {
+process.on('SIGINT', function () {
     console.info("\nStopping the server");
     process.exit();
 });
@@ -66,27 +66,26 @@ portfinder.getPortPromise()
         });
     })
     .catch((err) => {
-        if(err.toString().includes('Error: No open ports found') && config.findPort) {
+        if (err.toString().includes('Error: No open ports') && config.findPort) {
             console.info(`Port ${argv.port} not available, search for a new available port`);
+            // Recherche d'un port ouvert
+            portfinder.basePort = 8000;
+            portfinder.highestPort = 65535;
+            portfinder.getPortPromise()
+                .then((port) => {
+                    app.listen(port, () => {
+                        console.info(`New available port found: ${port}`);
+                        console.info(`Server starting on port ${port} (http://localhost:${port})`);
+                    });
+                })
+                .catch((err) => {
+                    console.err(err);
+                    console.info('Unable to start the server, end of execution');
+                    process.exit();
+                });
         } else {
             console.error(err.toString());
             console.info('Unable to start the server, end of execution');
             process.exit();
         }
     });
-
-// Recherche d'un port ouvert
-portfinder.basePort = 8000;
-portfinder.highestPort = 65535;
-portfinder.getPortPromise()
-    .then((port) => {
-        app.listen(port, () => {
-            console.info(`New available port found: ${port}`);
-            console.info(`Server starting on port ${port} (http://localhost:${port})`);
-        });
-    })
-    .catch((err) => {
-        console.err(err);
-        console.info('Unable to start the server, end of execution');
-        process.exit();
-    });

+ 30 - 0
node/package-lock.json

@@ -74,6 +74,11 @@
             "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
             "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
         },
+        "async": {
+            "version": "1.5.2",
+            "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
+            "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo="
+        },
         "asynckit": {
             "version": "0.4.0",
             "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@@ -949,6 +954,31 @@
             "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
             "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
         },
+        "portfinder": {
+            "version": "1.0.24",
+            "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.24.tgz",
+            "integrity": "sha512-ekRl7zD2qxYndYflwiryJwMioBI7LI7rVXg3EnLK3sjkouT5eOuhS3gS255XxBksa30VG8UPZYZCdgfGOfkSUg==",
+            "requires": {
+                "async": "^1.5.2",
+                "debug": "^2.2.0",
+                "mkdirp": "0.5.x"
+            },
+            "dependencies": {
+                "debug": {
+                    "version": "2.6.9",
+                    "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+                    "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+                    "requires": {
+                        "ms": "2.0.0"
+                    }
+                },
+                "ms": {
+                    "version": "2.0.0",
+                    "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+                    "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+                }
+            }
+        },
         "process-nextick-args": {
             "version": "2.0.1",
             "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",