-
Notifications
You must be signed in to change notification settings - Fork 11
contrib: integrate with systemd units #61
base: main
Are you sure you want to change the base?
Conversation
Type=notify | ||
NotifyAccess=all | ||
ExecStartPre=/bin/rm -f /run/traceloop.socket | ||
ExecStart=/bin/sh -c "/home/kai/kinvolk/traceloop/traceloop serve & while ! curl -fsS --unix-socket /run/traceloop.socket 'http://localhost/list' > /dev/null; do sleep 1; echo Waiting for traceloop to start up; done ; systemd-notify --ready; wait" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling systemd-notify
, you could do it in Golang:
https://vincent.bernat.ch/en/blog/2017-systemd-golang
https://github.com/coreos/go-systemd/blob/v22.3.2/daemon/sdnotify.go#L56
daemon.SdNotify(false, daemon.SdNotifyReady)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, with ignoring the return code (false, nil)
it should be fine when used outside of a systemd unit.
elif [ "$CMD" = list-sd-units ]; then | ||
echo " Traces Units" | ||
echo "------- -----" | ||
$CURL "http://localhost/list" | grep -o '\[systemd_.*\]' | cut -d _ -f 2 | sort | uniq -c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The systemd-specific commands *-sd could be added in the Go program, so that the shell script could be simplified. (could be in a follow-up PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And internally traceloop with still concatenate a special name or would you introduce a new attributes for Tracelet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess introducing new attributes but I have not given it much thought. Do you have a preference?
1b63177
to
4a2e4df
Compare
The benchmark script in contrib/ already used ExecStartPre to automatically set up systemd unit tracing. This was quite verbose and and also lacked the "+" prefix to refer to the host filesystem and run as root even if the unit processes are sandboxed. Document how to modify systemd units so that they register with traceloop. For convenience this is based on a traceloop service file and new helper tool traceloopctl in the contrib folder. The traceloopctl tool has a special systemd mode which follows a naming scheme for a better integration but the traceloopctl can also be used in the generic mode to interact with any trace.
4a2e4df
to
51b2479
Compare
The benchmark script in contrib/ already used ExecStartPre to
automatically set up systemd unit tracing. This was quite verbose and
and also lacked the "+" prefix to refer to the host filesystem and run
as root even if the unit processes are sandboxed.
Document how to modify systemd units so that they register with
traceloop. For convenience this is based on a traceloop service file
and new helper tool traceloopctl in the contrib folder. The
traceloopctl tool has a special systemd mode which follows a naming
scheme for a better integration but the traceloopctl can also be used
in the generic mode to interact with any trace.