Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the server config instead of env variables for the API port and the server hostname #488

Merged
merged 6 commits into from
Nov 18, 2019

Conversation

JonathanDCohen
Copy link
Contributor

No description provided.

src/shadowbox/README.md Show resolved Hide resolved
src/server_manager/install_scripts/install_server.sh Outdated Show resolved Hide resolved
src/shadowbox/docker/cmd.sh Outdated Show resolved Hide resolved
src/shadowbox/docker/run_action.sh Outdated Show resolved Hide resolved
src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
readonly STATE_DIR=$OUTLINE_DIR/persisted-state
readonly STATE_CONFIG=$STATE_DIR/shadowbox_server_config.json
mkdir -p $STATE_DIR && touch "$OUTLINE_DIR/config.json"
[[ -e $STATE_CONFIG ]] || echo "{\"hostname\":\"127.0.0.1\", \"apiPort\":2357}" > $STATE_CONFIG
source $ROOT_DIR/src/shadowbox/scripts/make_test_certificate.sh "${OUTLINE_DIR}"

# TODO: mount a folder rather than individual files.
declare -a docker_bindings=(
-v "$OUTLINE_DIR/config.json":/root/shadowbox/shadowbox_config.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use shadowbox_config.json instead of config.json. It's less confusing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, this line is not needed if you are mounting the state dir. Both config files go there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we can remove this line, the config isn't in the persisted-state directory.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See what we do in production:

declare -a docker_shadowbox_flags=(
--name shadowbox --restart=always --net=host
-v "${STATE_DIR}:${STATE_DIR}"
-e "SB_STATE_DIR=${STATE_DIR}"
-e "SB_PUBLIC_IP=${PUBLIC_HOSTNAME}"
-e "SB_API_PORT=${API_PORT}"
-e "SB_API_PREFIX=${SB_API_PREFIX}"
-e "SB_CERTIFICATE_FILE=${SB_CERTIFICATE_FILE}"
-e "SB_PRIVATE_KEY_FILE=${SB_PRIVATE_KEY_FILE}"
-e "SB_METRICS_URL=${SB_METRICS_URL:-}"
-e "SB_DEFAULT_SERVER_NAME=${SB_DEFAULT_SERVER_NAME:-}"

We actually mount the state dir. The config files are in it. Let's reproduce that, so it's closer to production and easier to understand. Using a different structure and file names for dev is confusing.

Copy link
Contributor Author

@JonathanDCohen JonathanDCohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Responded to comments. From offline discussion, also removed install script changes until after these changes get released. I messe dup Git royally though so definitely needs a close eye of review

src/server_manager/install_scripts/install_server.sh Outdated Show resolved Hide resolved
src/shadowbox/README.md Show resolved Hide resolved
src/shadowbox/docker/cmd.sh Outdated Show resolved Hide resolved
readonly STATE_DIR=$OUTLINE_DIR/persisted-state
readonly STATE_CONFIG=$STATE_DIR/shadowbox_server_config.json
mkdir -p $STATE_DIR && touch "$OUTLINE_DIR/config.json"
[[ -e $STATE_CONFIG ]] || echo "{\"hostname\":\"127.0.0.1\", \"apiPort\":2357}" > $STATE_CONFIG
source $ROOT_DIR/src/shadowbox/scripts/make_test_certificate.sh "${OUTLINE_DIR}"

# TODO: mount a folder rather than individual files.
declare -a docker_bindings=(
-v "$OUTLINE_DIR/config.json":/root/shadowbox/shadowbox_config.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we can remove this line, the config isn't in the persisted-state directory.

src/shadowbox/docker/run_action.sh Outdated Show resolved Hide resolved

const DEFAULT_PORT = 8081;
const apiPortNumber = Number(process.env.SB_API_PORT || DEFAULT_PORT);
const apiPortNumber = Number(serverConfig.data().apiPort || process.env.SB_API_PORT || DEFAULT_PORT);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also edited the error message to show the user where the config is located so it's easier for them to edit the config.

src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
@JonathanDCohen
Copy link
Contributor Author

Friendly ping :)

Copy link
Collaborator

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One minor comment below.
I'm sorry for the delay!

readonly STATE_DIR=$OUTLINE_DIR/persisted-state
readonly STATE_CONFIG=$STATE_DIR/shadowbox_server_config.json
mkdir -p $STATE_DIR && touch "$OUTLINE_DIR/config.json"
[[ -e $STATE_CONFIG ]] || echo "{\"hostname\":\"127.0.0.1\", \"apiPort\":2357}" > $STATE_CONFIG
source $ROOT_DIR/src/shadowbox/scripts/make_test_certificate.sh "${OUTLINE_DIR}"

# TODO: mount a folder rather than individual files.
declare -a docker_bindings=(
-v "$OUTLINE_DIR/config.json":/root/shadowbox/shadowbox_config.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See what we do in production:

declare -a docker_shadowbox_flags=(
--name shadowbox --restart=always --net=host
-v "${STATE_DIR}:${STATE_DIR}"
-e "SB_STATE_DIR=${STATE_DIR}"
-e "SB_PUBLIC_IP=${PUBLIC_HOSTNAME}"
-e "SB_API_PORT=${API_PORT}"
-e "SB_API_PREFIX=${SB_API_PREFIX}"
-e "SB_CERTIFICATE_FILE=${SB_CERTIFICATE_FILE}"
-e "SB_PRIVATE_KEY_FILE=${SB_PRIVATE_KEY_FILE}"
-e "SB_METRICS_URL=${SB_METRICS_URL:-}"
-e "SB_DEFAULT_SERVER_NAME=${SB_DEFAULT_SERVER_NAME:-}"

We actually mount the state dir. The config files are in it. Let's reproduce that, so it's closer to production and easier to understand. Using a different structure and file names for dev is confusing.

src/shadowbox/server/main.ts Outdated Show resolved Hide resolved
Copy link
Contributor Author

@JonathanDCohen JonathanDCohen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check carefully. I had to re do a lot of steps here as my git history got screwed up at some point.

src/shadowbox/docker/run_action.sh Outdated Show resolved Hide resolved
src/shadowbox/integration_test/test.sh Outdated Show resolved Hide resolved
Jon Cohen added 6 commits November 18, 2019 17:22
At some point down the line I royally screwed up my git history and
reverted a bunch of changes.  I'm not sure what or when, so I `git reset --hard 1cd28e4` and tried to redo my
past responses to comments from there.
@JonathanDCohen JonathanDCohen merged commit 46b7ee0 into master Nov 18, 2019
@sbruens sbruens deleted the cohenjon-use-config branch March 5, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants