Skip to content

Commit

Permalink
refactor and combine client and server.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham3121 committed May 1, 2024
1 parent bffeefa commit eee0fc1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ metadata:
{{- include "common.labels" . | nindent 4 }}
app.kubernetes.io/component: rathole
data:
myserver.toml: |
{{- if eq .Values.rathole.mode "server" }}
server.toml: |
[server]
bind_addr = "0.0.0.0:2333"
{{- end }}

{{- if eq .Values.rathole.mode "client" }}
client.toml: |
[client]
remote_addr = ""
3 changes: 1 addition & 2 deletions packages/grid/rathole/rathole.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ ENV APP_LOG_LEVEL="info"
COPY --from=build /rathole/target/release/rathole /app/rathole
RUN apt update && apt install -y netcat-openbsd vim
WORKDIR /app
COPY ./start-client.sh /app/start-client.sh
COPY ./start-server.sh /app/start-server.sh
COPY ./start.sh /app/start.sh
COPY ./client.toml /app/client.toml
COPY ./server.toml /app/server.toml
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
Expand Down
13 changes: 0 additions & 13 deletions packages/grid/rathole/start-client.sh

This file was deleted.

13 changes: 0 additions & 13 deletions packages/grid/rathole/start-server.sh

This file was deleted.

20 changes: 20 additions & 0 deletions packages/grid/rathole/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

APP_MODULE=server.main:app
LOG_LEVEL=${LOG_LEVEL:-info}
HOST=${HOST:-0.0.0.0}
PORT=${APP_PORT:-5555}
RELOAD="--reload"
DEBUG_CMD=""
RATHOLE_MODE=${RATHOLE_MODE:-server}

apt update && apt install -y nginx
nginx & exec python -m $DEBUG_CMD uvicorn $RELOAD --host $HOST --port $APP_PORT --log-level $LOG_LEVEL "$APP_MODULE" &

if [[ $RATHOLE_MODE == "server" ]]; then
/app/rathole server.toml
elif [[ $RATHOLE_MODE = "client" ]]; then
/app/rathole client.toml
else
echo "RATHOLE_MODE is set to an invalid value. Exiting."
fi

0 comments on commit eee0fc1

Please sign in to comment.