File: local-server.sh

package info (click to toggle)
nodejs 22.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 246,928 kB
  • sloc: cpp: 1,582,349; javascript: 582,017; ansic: 82,400; python: 60,561; sh: 4,009; makefile: 2,263; asm: 1,732; pascal: 1,565; perl: 248; lisp: 222; xml: 42
file content (55 lines) | stat: -rwxr-xr-x 1,275 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

# Copyright 2022 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

for i in "$@"; do
  case $i in
    -h|--help)
    echo "Starts a local server for V8's system anaylizer"
    echo "It's accessible http://localhost:8000"
    echo "Note: The server also exposes local binary information via 'nm'"
    exit;
  ;;
    *)
    echo "Invalid option: $i"
    exit 1;
  ;;
  esac
done

if ! command -v ws &> /dev/null
then
    echo "'ws' not found!"
    echo "Please install local-web-server:"
    echo "npm install local-web-server"
    echo ""
    exit
fi

TOOLS_DIR=`readlink "$0"` || TOOLS_DIR="$0";
TOOLS_DIR=`dirname "$TOOLS_DIR"`;
cd "$TOOLS_DIR/.."
TOOLS_DIR=`pwd -P`

if lsof -t -i TCP:8000; then
  echo "locahost:8000 is already in use. You can kill it with:"
  echo "lsof -t -i TCP:8000 | xargs kill"
  exit 1
fi

echo "Starting local symbol server"
ws --stack $TOOLS_DIR/system-analyzer/lws-middleware.js lws-static lws-index & PID=$!

# Kill server after 1h
for i in `seq 3600`; do
  if ps -p $PID > /dev/null 2>&1; then
    sleep 1;
  fi
done

if ps -p $PID > /dev/null 2>&1; then
  echo "Automatically killing the local server after timeout"
  kill $PID
fi