Skip to content

Commit

Permalink
Merge branch 'for-jens19'
Browse files Browse the repository at this point in the history
  • Loading branch information
mirabilos committed Nov 8, 2023
2 parents 981f80e + e4caf08 commit a8e571f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.pid
8 changes: 8 additions & 0 deletions DEVNOTES
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ Attach to a running instance:
2. Attach another server on a different port, when code-testing:

$ </proc/30837/environ xargs -0 mksh -c 'exec env "$@" ./run-produce.sh 8083' --
# or (new)
$ ./devattach.sh ./run-produce.sh 8083

3. Attach a PostgreSQL client:

$ </proc/30837/environ xargs -0o mksh -c 'exec env "$@" psql' --
# or (new)
$ ./devattach.sh

4. If needed, enable statement logging:

postgres=# ALTER SYSTEM SET log_statement TO 'all';
postgres=# SELECT pg_reload_conf();
$ tail -F /tmp/pg_virtualenv.*/log/postgresql-*-regress.log

5. Enter the session

postgres=# SELECT jensjs.use_session(1);
23 changes: 23 additions & 0 deletions devattach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/mksh

set -e

if (( $# == 0 )); then
# as default command
set -- psql
# as hint
print -ru2 '# SELECT jensjs.use_session(1);'
fi

devattach_sh_mydir=$(realpath "$0/..")
if [[ ! -s $devattach_sh_mydir/.pid ]]; then
print -ru2 E: cannot find pidfile
exit 1
fi
devattach_sh_pid=$(<"$devattach_sh_mydir/.pid")

devattach_sh_cmd='exec env "$@"'
for devattach_sh_x in "$@"; do
devattach_sh_cmd+=\ ${devattach_sh_x@Q}
done
exec </proc/"$devattach_sh_pid"/environ xargs -0o mksh -c "$devattach_sh_cmd" --
3 changes: 3 additions & 0 deletions mrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ set -A jdpids
function cleanup {
print -ru2 -- I: mrun.sh: cleaning up
trap - EXIT
rm -f .pid
[[ -z $pypid ]] || xsendsig "$pypid" -INT
[[ -z $shpid ]] || for p in "${shpid[@]}"; do
xsendsig "$p" -INT
Expand All @@ -143,6 +144,8 @@ function cleanup {
trap 'cleanup 0' INT
trap 'cleanup 1' EXIT TERM

echo $$ >.pid

# run python subprocess produce
{
trap - EXIT
Expand Down
3 changes: 3 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ shpid=
function cleanup {
print -ru2 -- I: run.sh: cleaning up
trap - EXIT
rm -f .pid
[[ -z $pypid ]] || xsendsig "$pypid" -INT
[[ -z $shpid ]] || xsendsig "$shpid" -INT
exit "$1"
}
trap 'cleanup 0' INT
trap 'cleanup 1' EXIT TERM

echo $$ >.pid

# run python subprocess produce
{
trap - EXIT
Expand Down

0 comments on commit a8e571f

Please sign in to comment.