Cron like daemon process that triggers executables based on messages received from pubsub topic.
Define the triggers in configuration file.
logging:
output: stdout
triggers:
- name: echo stuff
run:
timeout: 1h
concurrency: 1
exec: /bin/echo
args:
expression: {{ .Attributes.foobar }} {{ .Payload.foo.bar }}
pubsub:
project: sample123
subscription: execd
- name: date with format
run:
timeout: 20s
concurrency: 1
exec: date
args:
expression: +{{ .Attributes.format }}
pubsub:
project: sample123
subscription: execd
logging
spec:
output
- define the log output, accepted values arenone
,syslog
,stdout
andstderr
. Default isstdout
.
run
spec:
timeout
- if the message is not ack in this time, it will be redelivered to subscriptionconcurrency
- for receiving and processing messages for same trigger in parallelexec
- executableargs.expression
- go-template to parse the received message. The attributes are stored as.Attributes
and if the received data is injson
format, it is stored in.Payload
.
pubsub
spec:
project
- project id from where subscription should be foundsubscription
- subscription name
n.b pubsub-execd
does not create subscriptions, and they must exist before using them in configuration.
pubsub-execd -f /path/to/config.yaml
- Setup topic
execd-demo-topic
with subscriptionexec-demo-sub
in your project. - Start the daemon:
pubsub-execd -f sample.yaml
- Send message to topic:
gcloud pubsub topics publish \
--project=sample-project-123 execd-demo-topic \
--message='{"foo": {"bar": "and-this" }, "foobar": "not printed"}' \
--attribute=foobar=print-this,not=printed
- Expected output from daemon process:
2025/01/27 09:08:26 Running command: /bin/echo print-this and-this
print-this and-this
2025/01/27 09:08:26 Command /bin/echo executed successfully