@thesave/exec_command

0.1.5 • Public • Published

execCommand

A Jolie library to execute a command with arguments in a separate process in an asynchronous way.

It currently relies on the Process standard Java library and it is mainly an asynchronous/reactive take on the standard Jolie Exec library, where all commands are issued asynchronously and the user can monitor their execution by receiving messages from the standard output and error of the process, as well as the notification of its termination with the related exit code.

Usage Example

from @jolie.execCommand.main import ExecCommand
from console import Console

service main(){

  inputPort IN {
    location: "local"
    oneWay: stdErr, stdOut, exitNotification
  }

  embed ExecCommand as ExecCommand
  embed Console as Console

  execution { concurrent }

  init {
    with( request ){
      .args[#.args] = "ping"
      .args[#.args] = "-c"
      .args[#.args] = "5"
      .args[#.args] = "localhost"
      .stderrStreamOperation = "stdErr"
      .stdoutStreamOperation = "stdOut"
      .terminationOperation = "exitNotification"
    }
    start@ExecCommand( request )
  }

  main {
    [ stdErr( message ) ]{
      println@Console( "ERROR: " + message )()
    }
    [ stdOut( message ) ]{
      println@Console( "STDOUT: " + message )()
    }
    [ exitNotification( exitCode ) ]{
      println@Console( "Command terminated with exit code" + exitCode )()
      exit
    }
  }
}

Roadmap

  • [ ] support multiple process executions with correlation sets
  • [ ] support process kill-signal via process ids

Package Sidebar

Install

npm i @thesave/exec_command

Weekly Downloads

5

Version

0.1.5

License

LGPL 2.1

Unpacked Size

13.1 kB

Total Files

5

Last publish

Collaborators

  • thesave