Giter Site home page Giter Site logo

Comments (8)

mitchellh avatar mitchellh commented on August 24, 2024

I think this is because there is no newline on the end of the payload and the bash read built-in splits on newlines by default.

from serf.

justinclayton avatar justinclayton commented on August 24, 2024

Looks like you're correct:

[vagrant@source vagrant]$ serf event foo "bar
> baz"
2013/11/01 05:06:28 [INFO] agent: Received event: user-event: foo
2013/11/01 05:06:28 [DEBUG] Event 'user' script output:
/vagrant/event.sh triggered!

SERF_EVENT is user
SERF_SELF_NAME is target.serf.dev
SERF_SELF_ROLE is target
SERF_USER_EVENT is foo

BEGIN event data
bar
END event data
/vagrant/event.sh finished!

Should have caught that myself, thanks. In my defense, however, I was pulling together the example event handler script from here and the example user event from here. Perhaps either serf should add a trailing newline for user events since all the other events seem to have them (though I could see scenarios where you may not want that), or the docs should flesh out this behavior a bit more with additional examples. Thoughts?

from serf.

mitchellh avatar mitchellh commented on August 24, 2024

I think I should make a note in the docs. Tagged. Thanks!

from serf.

justinclayton avatar justinclayton commented on August 24, 2024

Thanks for your crazy quick response!

from serf.

armon avatar armon commented on August 24, 2024

Fixed in abf697f

from serf.

justinclayton avatar justinclayton commented on August 24, 2024

FYI this appears to still be happening in 0.4.1. Below is an example.

Triggering the event:

# serf version
Serf v0.4.1
Agent Protocol: 3 (Understands back to: 1)
# serf event myevent "foo
> bar"
Event 'myevent' dispatched! Coalescing enabled: true

And the output of serf monitor -log-level=debug:

2014/02/12 23:25:32 [INFO] agent: Received event: user-event: myevent
Event Info:
  Coalesce: true
  Event: "user"
  LTime: 9
  Name: "myevent"
  Payload: []byte{0x66, 0x6f, 0x6f, 0xa, 0x62, 0x61, 0x72}
2014/02/12 23:25:32 [DEBUG] Event 'user' script output:
/etc/serf/handlers/myevent.sh triggered!

SERF_EVENT is user
SERF_USER_EVENT is myevent
SERF_USER_LTIME is 9

BEGIN event data
foo
END event data
/etc/serf/handlers/myevent.sh finished!

And the handler script itself:

#!/bin/bash

echo
echo "$0 triggered!"
echo
echo "SERF_EVENT is ${SERF_EVENT}"
echo "SERF_USER_EVENT is ${SERF_USER_EVENT}"
echo "SERF_USER_LTIME is ${SERF_USER_LTIME}"
echo
echo "BEGIN event data"
while read line; do
  echo $line
done
echo "END event data"
echo "$0 finished!"
echo

from serf.

armon avatar armon commented on August 24, 2024

This was indeed a regression. Fixed in a07ad67.

from serf.

justinclayton avatar justinclayton commented on August 24, 2024

Thanks!

from serf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.