title: Turn off CS:GO Dedicated Server via Node.js child_process
body: <p><br><br>
  I've been trying to programmatically control multiple Counter Strike: Global Offensive dedicated servers. Everything works fine, but I'm having trouble turning it completely off. When you turn on the server, it creates two processes: <code>srcds_run</code> and <code>srcds_linux</code>. I can easily do <a href="https://nodejs.org/api/child_process.html#child_process_child_kill_signal" rel="nofollow">child_process.kill()</a>, and it will turn off the <code>srcds_run</code> process, but the <code>srcds_linux</code> process keeps on running, even when the server is off. If I try to kill <strong>all</strong> <code>srcds_linux</code> processes, then it will kill <strong>all</strong> of the CSGO servers, even if I'm trying to turn off only one. Is there any way to select the corresponding <code>srcds_run</code> and <code>srcds_linux</code> processes?
  <br><br>
  This is my code so far:
  <br><br></p>
  
  <pre><code>// Turns on the server if not already on
  
  Server.prototype.start = function(callback) {
  
      if(!this.online) {
  
          // Turn server on
          console.log('Starting server');
  
          this.process = spawn(this.directory + '/srcds_run', ['-game csgo', '-console', '-usercon', '+game_type 0', '+game_mode 0', '+mapgroup mg_active', '+map de_dust2', '+sv_setsteamaccount ' + this.token], { cwd: this.directory});
  
          this.process.stderr.on('data', function(err) {
              console.log('Error: ' + err);
          });
  
          this.process.stdin.on('data', function(chunk) {
              console.log('stdin: ' + chunk);
          });
  
          this.process.stdout.on('data', function(chunk) {
              console.log('stdout: ' + chunk);
          });
  
      }
  
      this.online = true;
      callback();
  }
  
  // Turns off the server if not already off
  
  Server.prototype.stop = function(callback) {
  
      if(this.online) {
  
          // Turn server off
          console.log('Stopping server');
          this.process.kill();
  
      }
  
      this.online = false;
      callback();
  }
  </code></pre>
  
  <p>I'm using an Ubuntu Server and am using the <a href="https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options" rel="nofollow">child_process.spawn module</a> on node.js
  <br>
  I appreciate the help :)</p>