Skip to content

Upgrade to child_process.spawn #12

@khilnani

Description

@khilnani

From Felix -

rather than use exec I think you should use spawn.
this is how I spawn scsynth from inside supercollider.js

I will do the same thing for sclang when I get around to it.
then it should be easy to use this from other projects.

something like
scjs = requires("supercolliderjs");

sclang = new new SCLang();
sclang.start(function() {
// language is started now
});
sclang.on("quit",function() { });
etc.

here's the version for a local scsynth: LocalServer()

https://github.com/crucialfelix/supercolliderjs/blob/master/lib/localserver.js

var spawn = require('child_process').spawn;

    console.log( this.options.cwd + this.options.cmd );
    this.process = spawn(this.options.cwd + this.options.cmd,this.args(),
        {
            stdio: ['pipe', 'pipe', 'pipe'],
            cwd: this.options.cwd

        });
    console.log("spawned " + this.process.pid);
    this.process.on('exit',function(code){
        console.log("Server exited " + code);
    });
    this.process.stdout.on('data',function(data){
        console.log(" " + data);
    });
    this.process.stderr.on('data',function(data){
        console.log("! " + data);
    });

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions