bin/entrypoint.sh now has each of its steps in a function, and main "$@" at the end calls them in order, as the shell section of CODE_STYLEGUIDE.md asks (#163). The functions are check_port, write_trusted_proxies, prepare_data_dir, start_backend, start_nginx, wait_for_stop_or_exit, stop_both and exit_with_status; running is unchanged. Each comment stays above the code it described. The script is still POSIX sh, and the reason given for no set -e stays.
Not visible from the diff alone:
main sets the TERM and INT trap after the data directory is prepared and before either process starts, which is where it was before.
backend, nginx and stop_requested are shared by several functions and stay global, since POSIX sh has no local. An exit inside a function ends the script, as it did at the top level.
Judgement call: the 8081 message is now passed to echo as two arguments so its line fits in 80 columns; it prints the same text.
Run in the image from make docker, once with the new script and once with the one from next mounted over it: a normal start, PORT set to abc, 0, 70000, a 20-digit number and 8081, TRUSTED_PROXIES=1.2.3, DATA_DIR=/srv/reports, docker stop, INT, and nginx -s quit inside the container.
Model: opus-5-5
`bin/entrypoint.sh` now has each of its steps in a function, and `main "$@"` at the end calls them in order, as the shell section of `CODE_STYLEGUIDE.md` asks (https://git.eeqj.de/sneak/netwatch/issues/163). The functions are `check_port`, `write_trusted_proxies`, `prepare_data_dir`, `start_backend`, `start_nginx`, `wait_for_stop_or_exit`, `stop_both` and `exit_with_status`; `running` is unchanged. Each comment stays above the code it described. The script is still POSIX sh, and the reason given for no `set -e` stays.
Not visible from the diff alone:
- `main` sets the TERM and INT trap after the data directory is prepared and before either process starts, which is where it was before.
- `backend`, `nginx` and `stop_requested` are shared by several functions and stay global, since POSIX sh has no `local`. An `exit` inside a function ends the script, as it did at the top level.
Judgement call: the `8081` message is now passed to `echo` as two arguments so its line fits in 80 columns; it prints the same text.
Run in the image from `make docker`, once with the new script and once with the one from `next` mounted over it: a normal start, `PORT` set to `abc`, `0`, `70000`, a 20-digit number and `8081`, `TRUSTED_PROXIES=1.2.3`, `DATA_DIR=/srv/reports`, `docker stop`, INT, and `nginx -s quit` inside the container.
Model: opus-5-5
bin/entrypoint.sh was top-level code with one helper; the shell section
of the code style guide asks for every step in a function and a main
called at the end. The PORT and TRUSTED_PROXIES checks, the data
directory, starting each process, the wait loop, stopping both and the
exit are now functions, which main calls in order, setting the stop
trap before either process starts. It stays POSIX sh with no set -e.
Messages and exit codes are unchanged; the 8081 message is passed to
echo as two arguments so its line fits in 80 columns.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
bin/entrypoint.shnow has each of its steps in a function, andmain "$@"at the end calls them in order, as the shell section ofCODE_STYLEGUIDE.mdasks (#163). The functions arecheck_port,write_trusted_proxies,prepare_data_dir,start_backend,start_nginx,wait_for_stop_or_exit,stop_bothandexit_with_status;runningis unchanged. Each comment stays above the code it described. The script is still POSIX sh, and the reason given for noset -estays.Not visible from the diff alone:
mainsets the TERM and INT trap after the data directory is prepared and before either process starts, which is where it was before.backend,nginxandstop_requestedare shared by several functions and stay global, since POSIX sh has nolocal. Anexitinside a function ends the script, as it did at the top level.Judgement call: the
8081message is now passed toechoas two arguments so its line fits in 80 columns; it prints the same text.Run in the image from
make docker, once with the new script and once with the one fromnextmounted over it: a normal start,PORTset toabc,0,70000, a 20-digit number and8081,TRUSTED_PROXIES=1.2.3,DATA_DIR=/srv/reports,docker stop, INT, andnginx -s quitinside the container.Model: opus-5-5
Review passed.
Model: opus-5-5