[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] Re: Tell sclang the server is already running?



Tom Murphy wrote
> Anyone know the right way to do this?

To cover all the bases, I would recommend this:

// Do this once, after recompiling the class library
~myServer = Server(\external, NetAddr(...));

(
ServerBoot.add({ |server|
	var port = if(server.inProcess) { thisProcess.pid } { server.addr.port };
	server.slotPut(\serverInterface, ServerShmInterface(port));
}, ~myServer);
)

// Do this when you want to check for a server
~myServer.startAliveThread;

Notes:

- This is a bit of a naughty hack: serverInterface is properly a private
variable. For whatever reason (probably just a developer mistake), Server
doesn't have a dedicated method to open the shared memory interface.
Instead, that logic is buried within the "boot" method. So, currently, the
only way to establish a shared memory interface when the server is being
booted by any method other than calling "boot," you have to bypass the
normal interface restrictions. I don't like it, but until somebody properly
modularizes this, that's what we've got. TL;DR - be careful.

- If you don't give a server object to ServerBoot.add, the action will fire
for any server object. So, if you do 's.boot', then the boot method will
open a shared memory interface and ServerBoot will also try to open a shared
memory interface. I haven't tested this, but I can imagine it might not go
well. So I strongly recommend creating your own Server instance to watch for
any remotely-started process, and give that instance to ServerBoot
(restricting the action to that instance only).

- You can startAliveThread anytime before or after externally starting the
server. But (IIRC) aServer.quit stops the alive thread, so you will have to
redo it after quit.

HTH,
hjh



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/Tell-sclang-the-server-is-already-running-tp7629622p7629695.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/