Skip to content

Commit

Permalink
use environment for CA/PVA ports
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Dec 2, 2024
1 parent fe2fc21 commit ebe56ce
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
3 changes: 3 additions & 0 deletions template/.devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EPICS_CA_SERVER_PORT=5064
EPICS_CA_REPEATER_PORT=5065
EPICS_PVA_SERVER_PORT=5075
21 changes: 11 additions & 10 deletions template/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@
"--security-opt=label=disable"
],
"appPort": [
// Expose Channel Access on the hosts loopback interface
// NOTE: change the first port number to run more than one devcontainer
// on the same host.
// Expose Channel Access ports on the host's loopback interface
// Note: update the environment variables in .devcontainer/.env to
// change the ports when running multiple devcontainers simultaneously,
// then use e.g. EPICS_CA_ADDR_LIST="127.0.0.1:5064 127.0.0.1:6064"
// for clients to connect to multiple devcontainers' PVs.
//
// To access two devcontainers from the host for example:
// EPICS_CA_ADDR_LIST="127.0.0.1:5064 127.0.0.1:6064"
"127.0.0.1:5064:5064/udp",
"127.0.0.1:5064-5065:5064-5065",
// "127.0.0.1:5076:5076/udp", PVA UDP does not work into container network
// expose pva name server access via TCP
"5075-5076:5075-5076"
"127.0.0.1:${remoteEnv:EPICS_CA_SERVER_PORT}:${remoteEnv:EPICS_CA_SERVER_PORT}/udp",
"127.0.0.1:${remoteEnv:EPICS_CA_SERVER_PORT}:${remoteEnv:EPICS_CA_SERVER_PORT}",
"127.0.0.1:${remoteEnv:EPICS_CA_REPEATER_PORT}:${remoteEnv:EPICS_CA_REPEATER_PORT}",
//
// Expose the PVA name server port on all host interfaces
"${remoteEnv:EPICS_PVA_SERVER_PORT}:${remoteEnv:EPICS_PVA_SERVER_PORT}"
],
// Mount the parent of the project folder so we can access peer projects
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
Expand Down
12 changes: 10 additions & 2 deletions template/opi/phoebus-launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
thisdir=$(realpath $(dirname $0))
workspace=$(realpath ${thisdir}/..)

# update settings.ini with CA and PVA ports
source ${workspace}/.devcontainer/.env
cat ${workspace}/opi/settings.ini |
sed -r \
-e "s|5064|${EPICS_CA_SERVER_PORT}|" \
-e "s|5075|${EPICS_PVA_SERVER_PORT}|" \
-e "s|5065|${EPICS_CA_REPEATER_PORT}|" > /tmp/settings.ini

settings="
-resource ${workspace}/opi/auto-generated/index.bob
-settings ${workspace}/opi/settings.ini
-settings /tmp/settings.ini
"

if which phoebus.sh &>/dev/null ; then
Expand Down Expand Up @@ -40,8 +48,8 @@ else
image="ghcr.io/epics-containers/ec-phoebus:latest"

settings="
-settings /workspace/opi/settings.ini
-resource /workspace/opi/auto-generated/index.bob
-settings /tmp/settings.ini
"

set -x
Expand Down
8 changes: 8 additions & 0 deletions template/opi/settings.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# NOTE: port numbers are defaults only
# this script to be processed with sed to replace port numbers
# see phoebus-launch.sh

# point at local host for channel access
org.phoebus.pv.ca/addr_list=127.0.0.1
org.phoebus.pv.ca/server_port=5064
org.phoebus.pv.ca/repeater_port=5065
# point at local host for pvAccess name server
org.phoebus.pv.pva/epics_pva_name_servers=127.0.0.1
org.phoebus.pv.pva/server_port=5075

0 comments on commit ebe56ce

Please sign in to comment.