Skip to content

Commit

Permalink
More sh->python use: supervisor.sh.
Browse files Browse the repository at this point in the history
Deal with more bazel/python non-sense. py_binary cannot be made with an
imported entry point. There has to be a redundant local wrapper.
  • Loading branch information
jiceatscion committed Oct 30, 2024
1 parent 56ff27e commit 744d447
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
5 changes: 4 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ pkg_tar(
package_dir = "",
)

# This contains all of the binaries needed to run the topology generator.
# This contains all of the binaries needed to run the topology generator
# and start a local stack.
pkg_tar(
name = "scion-topo",
srcs = [
"//tools:set_ipv6_addr",
"//tools:topodot",
"//tools:topogen",
"//tools:supervisord",
"//tools:supervisorctl",
],
mode = "0755",
)
Expand Down
20 changes: 20 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ py_binary(
],
)

py_binary(
name = "supervisord",
srcs = ["supervisord.py"],
deps = [
requirement("supervisor"),
requirement("supervisor-wildcards"),
],
visibility = ["//visibility:public"],
)

py_binary(
name = "supervisorctl",
srcs = ["supervisorctl.py"],
deps = [
requirement("supervisor"),
requirement("supervisor-wildcards"),
],
visibility = ["//visibility:public"],
)

py_binary(
name = "topogen",
srcs = ["topogen.py"],
Expand Down
4 changes: 2 additions & 2 deletions tools/supervisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mkdir -p logs
OPTIONS="$@"
CONF_FILE="tools/supervisord.conf"
if [ ! -e /tmp/supervisor.sock ]; then
supervisord -c $CONF_FILE
bin/supervisord -c $CONF_FILE
fi
supervisorctl -c $CONF_FILE $OPTIONS
bin/supervisorctl -c $CONF_FILE $OPTIONS

13 changes: 13 additions & 0 deletions tools/supervisorctl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# This is exact replica of supervisord's entry point because I haven't
# found an intelligible way of creating a py_binary target that doesn't
# define its own entry point.

import re
import sys
from supervisor.supervisorctl import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
13 changes: 13 additions & 0 deletions tools/supervisord.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# !/usr/bin/python3
# -*- coding: utf-8 -*-

# This is exact replica of supervisord's entry point because I haven't
# found an intelligible way of creating a py_binary target that doesn't
# define its own entry point.

import re
import sys
from supervisor.supervisord import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

0 comments on commit 744d447

Please sign in to comment.