File: serve_benchmark

package info (click to toggle)
ruby-active-model-serializers 0.10.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,752 kB
  • sloc: ruby: 13,138; sh: 53; makefile: 6
file content (39 lines) | stat: -rwxr-xr-x 728 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env bash
set -e

case "$1" in

  start)
  config="${CONFIG_RU:-test/benchmark/config.ru}"
  bundle exec ruby -Ilib -S rackup "$config" --daemonize --pid tmp/benchmark_app.pid --warn --server webrick
  until [ -f 'tmp/benchmark_app.pid' ]; do
    sleep 0.1 # give it time to start.. I don't know a better way
  done
  cat tmp/benchmark_app.pid
  true
  ;;

  stop)
  if [ -f 'tmp/benchmark_app.pid' ]; then
    kill -TERM $(cat tmp/benchmark_app.pid)
  else
    echo 'No pidfile'
    false
  fi
  ;;

  status)
  if [ -f 'tmp/benchmark_app.pid' ]; then
    kill -0 $(cat tmp/benchmark_app.pid)
    [ "$?" -eq 0 ]
  else
    echo 'No pidfile'
    false
  fi
  ;;

  *)
  echo "Usage: $0 [start|stop|status]"
  ;;

esac