6

Is there a way to launch a set of steams and taps that have been defined when a new instance of spring xd is launched?

The scenario is this: We've done some prototyping on our dev systems, but now when we'd like to build and release this to a test team. We'd like to automate most of the background work and the user needs to just worry about the output from the streams and not have to worry about the streams or their definitions or their deployment.

To facilitate this is there any runtime configurations we can use?

UPDATE: Our current approach involves writing a shell script to make some rest calls to the Spring API to create and deploy the required streams.

Arun Jose
  • 365
  • 4
  • 16

1 Answers1

11

The shell maintains a log of user commands:

spring-shell.log

You can edit it after creating your stream(s) (or create a file with shell commands) and then use the script command:

xd:>script foo.xd

or

$ bin/xd-shell < foo.xd

(the .xd suffix is not required, the file name can be anything).

EDIT (comment below)...

This does come with the caveat that bin/xd-shell < foo.xd will run all commands regardless of success or failure, and xd-shell --cmdfile foo.xd will terminate execution with an exit code immediately should a command fail.

Ricardo Stuven
  • 4,704
  • 2
  • 34
  • 36
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Thanks again Gary. Was this detail in the documentation by any chance? I looked around but didn't see anything. – Arun Jose Jul 18 '14 at 12:48
  • I am not sure if it's explicitly mentioned in the XD docs, but the XD shell is based on the [Spring Shell](https://github.com/spring-projects/spring-shell#readme) and it's mentioned there. Also you can type `help` to get a list of all commands. – Gary Russell Jul 18 '14 at 12:58
  • 2
    you can also use `$ xd-shell --cmdfile foo.xd` – Mark Pollack Jul 18 '14 at 13:01
  • There is some info in the [docs](https://github.com/spring-projects/spring-xd/wiki/Shell#executing-a-script) for future ref – Mark Pollack Jul 18 '14 at 13:06
  • 1
    In distributed mode, would this mean I try $ xd-container --cmdfile foo.xd – Arun Jose Jul 18 '14 at 13:31
  • No; the command file is not passed to the container, it is passed to the shell (which uses ReST to talk to the admin node). The admin node then selects which container to deploy it on. – Gary Russell Jul 18 '14 at 13:37
  • I've been using info a lot more than I've used help. I think that's exactly what the doctor ordered! – Arun Jose Jul 18 '14 at 20:34
  • 1
    This does come with the caveat that `bin/xd-shell < foo.xd` will run all commands regardless of success or failure, and `xd-shell --cmdfile foo.xd` will terminate execution with an exit code immediately should a command fail. – Brandon McKenzie Apr 28 '15 at 17:02