Advertisement
scanyboss

start server process

Oct 19th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const {AutoLanguageClient} = require('atom-languageclient');
  2. const cp = require('child_process');
  3.  
  4. class YouDSLLanguageClient extends AutoLanguageClient {
  5.     getGrammarScopes() {
  6.         return ['source.yourdsl']
  7.     }
  8.  
  9.     getLanguageName() {
  10.         return 'YourDSL'
  11.     }
  12.  
  13.     getServerName() {
  14.         return 'YourDsl'
  15.     }
  16.  
  17.     startServerProcess(projectPath) {
  18.         const serverHome = path.join(__dirname, 'server');
  19.         const args = [];
  20.         args.push(
  21.             '-jar', path.join(serverHome,'org.example.yourdsl.ide-1.0.0-SNAPSHOT-ls.jar')
  22.         );
  23.         console.log(args);
  24.         console.log(serverHome);
  25.         const childProcess = cp.spawn('java', args,{ cwd: serverHome });
  26.         this.captureServerErrors(childProcess);
  27.         childProcess.on('close', exitCode => {
  28.             if (!childProcess.killed) {
  29.                 atom.notifications.addError('IDE-YourDSL language server stopped unexpectedly.', {
  30.                     dismissable: true,
  31.                     description: this.processStdErr ? `<code>${this.processStdErr}</code>` : `Exit code ${exitCode}`
  32.                 })
  33.             }
  34.         });
  35.         return childProcess;
  36.     }
  37. }
  38.  
  39. module.exports = new YouDSLLanguageClient();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement