]>
sourceware.org Git - systemtap.git/blob - stap-serverd
3 # Compile server manager for systemtap
5 # Copyright (C) 2008 Red Hat Inc.
7 # This file is part of systemtap, and is free software. You can
8 # redistribute it and/or modify it under the terms of the GNU General
9 # Public License (GPL); either version 2, or (at your option) any
12 # This script publishes its presence on the network and then listens for
13 # incoming connections. When a connection is detected, the stap-server script
14 # is run to handle the request.
17 trap 'handle_sigint' SIGINT
19 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # function: initialization PORT
23 function initialization
{
25 tmpdir_prefix_serverd
=stap.serverd
28 test "X$port" = "X" && port
=65000
31 # function: advertise_presence
33 # Advertise the availability of the server on the network.
34 function advertise_presence
{
35 # Build up a string representing our server's properties.
36 # TODO: this needs fleshing out.
38 local sysinfo
=`uname -r`
41 # Call avahi-publish-service to advertise our presence.
42 avahi-publish-service
"Systemtap Compile Server on `uname -n`" \
43 $avahi_type $port $txt > /dev
/null
2>&1 &
45 echo "Systemtap Compile Server on `uname -n` listening on port $port"
50 # Listen for and handle requests to the server.
52 # Work in a temporary directory
53 tmpdir
=`mktemp -dt $tmpdir_prefix_serverd.XXXXXX` || \
54 fatal
"ERROR: cannot create temporary directory " $tmpdir
57 # Create a fifo for communicating with the server
58 local fifo_name
=$tmpdir_prefix_serverd.fifo
59 mknod
$fifo_name p || \
60 fatal
"ERROR: cannot create temporary fifo " $tmpdir/$fifo_name
62 # Loop forever accepting requests
65 nc
-l $port < $fifo_name | stap-server $
((port
+ 1)) > $fifo_name 2>&1
69 # function: fatal [ MESSAGE ]
72 # Prints its arguments to stderr and exits
78 # function: handle_sigint
80 # Terminate gracefully when SIGINT is received.
81 function handle_sigint
{
82 echo "$0: received SIGINT. Exiting."
88 #-----------------------------------------------------------------------------
89 # Beginning of main line execution.
90 #-----------------------------------------------------------------------------
This page took 0.044973 seconds and 6 git commands to generate.