cannc4/Siren

Server: Not possible to stop & restart the server without restarting the app

jarmitage opened this issue · 3 comments

Throws an error such as:

events.js:165
[0]       throw er; // Unhandled 'error' event
[0]       ^
[0]
[0] Error: listen EADDRINUSE :::4003
[0]     at Server.setupListenHandle [as _listen2] (net.js:1342:14)
[0]     at listenInCluster (net.js:1383:12)
[0]     at Server.listen (net.js:1471:7)
[0]     at Server.listen.Server.attach (/Users/jarm/Documents/git/livecode/Siren/node_modules/socket.io/lib/index.js:228:9)
[0]     at new Server (/Users/jarm/Documents/git/livecode/Siren/node_modules/socket.io/lib/index.js:52:17)
[0]     at Function.Server (/Users/jarm/Documents/git/livecode/Siren/node_modules/socket.io/lib/index.js:40:41)
[0]     at REPL.doSpawn (/Users/jarm/Documents/git/livecode/Siren/server/app.js:30:28)
[0]     at REPL.start (/Users/jarm/Documents/git/livecode/Siren/server/app.js:324:10)
[0]     at startSiren (/Users/jarm/Documents/git/livecode/Siren/server/app.js:425:33)
[0]     at /Users/jarm/Documents/git/livecode/Siren/server/app.js:781:9
[0]     at Layer.handle [as handle_request] (/Users/jarm/Documents/git/livecode/Siren/node_modules/express/lib/router/layer.js:95:5)
[0]     at next (/Users/jarm/Documents/git/livecode/Siren/node_modules/express/lib/router/route.js:137:13)
[0]     at Route.dispatch (/Users/jarm/Documents/git/livecode/Siren/node_modules/express/lib/router/route.js:112:3)
[0]     at Layer.handle [as handle_request] (/Users/jarm/Documents/git/livecode/Siren/node_modules/express/lib/router/layer.js:95:5)
[0]     at /Users/jarm/Documents/git/livecode/Siren/node_modules/express/lib/router/index.js:281:22
[0]     at Function.process_params (/Users/jarm/Documents/git/livecode/Siren/node_modules/express/lib/router/index.js:335:12)
[0] Emitted 'error' event at:
[0]     at emitErrorNT (net.js:1362:8)
[0]     at process._tickCallback (internal/process/next_tick.js:114:19)
[0] node server/start.js exited with code 1

Sometimes scsynth or node gets stuck in the background even if you close the app.
In order to boot the server in Siren, you need to make sure that those aren't running and the sockets are free.
you can quit them using Activity Monitor on mac

It seems like another application is using the port 4003 (most likely node). Could you run a quick netstat to make sure?

Here's another output from attempting to stop the server from within Siren

[0] debug  : SuperColliderJS.interpret("cjh7j6s8t00024bvyc5l3hdrg","s.quit;",nil,false,false,false);
[0] debug  :
[0]            SUPERCOLLIDERJS:cjh7j6s8t00024bvyc5l3hdrg:CAPTURE:START
[0]            server 'localhost' disconnected shared memory interface
[0] debug  : '/quit' sent
[0] debug  :
[0]            SUPERCOLLIDERJS:cjh7j6s8t00024bvyc5l3hdrg:CAPTURE:END
[0] debug  :
[0]            SUPERCOLLIDERJS:cjh7j6s8t00024bvyc5l3hdrg:START:Result
[0]            SUPERCOLLIDERJS:cjh7j6s8t00024bvyc5l3hdrg:CHUNK:{"string": "localhost","compileString": "s","class": "Server"}
[0]            SUPERCOLLIDERJS:cjh7j6s8t00024bvyc5l3hdrg:END:Result
[0]            SUPERCOLLIDERJS.interpreted
[0]  ### sendSC:  { string: 'localhost', compileString: 's', class: 'Server' }
[0] debug  : ->
[0] Unhandled rejection TypeError: Cannot read property 'status' of null
[0]     at /Users/jarm/Documents/git/livecode/Siren/server/app.js:391:15
[0]     at tryCatcher (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/util.js:16:23)
[0]     at Promise._settlePromiseFromHandler (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/promise.js:512:31)
[0]     at Promise._settlePromise (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/promise.js:569:18)
[0]     at Promise._settlePromise0 (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/promise.js:614:10)
[0]     at Promise._settlePromises (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/promise.js:693:18)
[0]     at Async._drainQueue (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/async.js:133:16)
[0]     at Async._drainQueues (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/async.js:143:10)
[0]     at Immediate.Async.drainQueues [as _onImmediate] (/Users/jarm/Documents/git/livecode/Siren/node_modules/bluebird/js/release/async.js:17:14)
[0]     at runCallback (timers.js:763:18)
[0]     at tryOnImmediate (timers.js:734:5)
[0]     at processImmediate (timers.js:716:5)
[0] debug  : RESULT = 0