Artifact
b616e6dbbda6a621b023b159d24826292e77009a93553a31537159eed382e621 :
Executable file
tools/fslsrv
— part of check-in
[1cbcb38c]
at
2022-10-07 22:15:16
on branch trunk
— Assorted updates surrounding my fslsrv wrapper:
Reflected improvements from the tangentsoft.com version into this
simpler alternative. Although we don't generally recommend use of
this script any more, preferring systemd to get autostart on boot
and autorestart on crash, www/server/any/none.md still refers to
this script, and it feels like a regression to remove it. If
someone is interested in simple-as-possible SCGI service, fslsrv
is a fit companion.
Removed direct reference to fslsrv from www/server/debian/service.md
since the indirect reference via the SCGI doc suffices.
The full-strength nginx doc now refers to both of these fslsrv
variants in a handwavy way, since it's outside the scope of that
doc to care how you get your background SCGI servers running.
(user:
wyoung
size: 1224)
[more...]
0000: 23 21 2f 62 69 6e 2f 62 61 73 68 0a 46 4f 53 53 #!/bin/bash.FOSS
0010: 49 4c 3d 66 6f 73 73 69 6c 0a 50 47 41 52 47 53 IL=fossil.PGARGS
0020: 3d 22 2d 50 20 31 22 0a 4f 4c 44 50 49 44 3d 60 ="-P 1".OLDPID=`
0030: 70 67 72 65 70 20 2d 50 20 31 20 66 6f 73 73 69 pgrep -P 1 fossi
0040: 6c 60 0a 53 49 54 45 3d 68 74 74 70 73 3a 2f 2f l`.SITE=https://
0050: 65 78 61 6d 70 6c 65 2e 63 6f 6d 0a 50 4f 52 54 example.com.PORT
0060: 3d 31 32 33 34 35 0a 0a 69 66 20 5b 20 22 24 31 =12345..if [ "$1
0070: 22 20 3d 20 22 2d 66 22 20 5d 20 3b 20 74 68 65 " = "-f" ] ; the
0080: 6e 20 50 47 41 52 47 53 3d 20 3b 20 73 68 69 66 n PGARGS= ; shif
0090: 74 20 3b 20 66 69 0a 0a 69 66 20 5b 20 2d 6e 20 t ; fi..if [ -n
00a0: 22 24 4f 4c 44 50 49 44 22 20 5d 0a 74 68 65 6e "$OLDPID" ].then
00b0: 0a 20 20 20 20 65 63 68 6f 20 22 4b 69 6c 6c 69 . echo "Killi
00c0: 6e 67 20 72 75 6e 6e 69 6e 67 20 46 6f 73 73 69 ng running Fossi
00d0: 6c 20 73 65 72 76 65 72 20 66 69 72 73 74 2e 2e l server first..
00e0: 2e 22 0a 20 20 20 20 70 6b 69 6c 6c 20 24 50 47 .". pkill $PG
00f0: 41 52 47 53 20 66 6f 73 73 69 6c 0a 0a 20 20 20 ARGS fossil..
0100: 20 66 6f 72 20 69 20 69 6e 20 24 28 73 65 71 20 for i in $(seq
0110: 33 30 29 0a 20 20 20 20 64 6f 0a 20 20 20 20 20 30). do.
0120: 20 20 20 69 66 20 5b 20 2d 6e 20 22 24 28 70 67 if [ -n "$(pg
0130: 72 65 70 20 24 50 47 41 52 47 53 20 66 6f 73 73 rep $PGARGS foss
0140: 69 6c 29 22 20 5d 0a 20 20 20 20 20 20 20 20 74 il)" ]. t
0150: 68 65 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 hen.
0160: 69 66 20 5b 20 24 69 20 2d 65 71 20 31 20 5d 0a if [ $i -eq 1 ].
0170: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 65 6e then
0180: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
0190: 20 65 63 68 6f 20 2d 6e 20 22 57 61 69 74 69 6e echo -n "Waitin
01a0: 67 20 66 6f 72 20 69 74 20 74 6f 20 64 69 65 2e g for it to die.
01b0: 2e 2e 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 ..".
01c0: 65 6c 73 65 0a 20 20 20 20 20 20 20 20 20 20 20 else.
01d0: 20 20 20 20 20 65 63 68 6f 20 2d 6e 20 2e 0a 20 echo -n ..
01e0: 20 20 20 20 20 20 20 20 20 20 20 66 69 0a 20 20 fi.
01f0: 20 20 20 20 20 20 20 20 20 20 73 6c 65 65 70 20 sleep
0200: 27 30 2e 31 27 0a 20 20 20 20 20 20 20 20 65 6c '0.1'. el
0210: 73 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 62 se. b
0220: 72 65 61 6b 0a 20 20 20 20 20 20 20 20 66 69 0a reak. fi.
0230: 20 20 20 20 20 20 20 20 65 63 68 6f 0a 20 20 20 echo.
0240: 20 64 6f 6e 65 0a 0a 20 20 20 20 6b 69 6c 6c 61 done.. killa
0250: 6c 6c 20 2d 39 20 66 6f 73 73 69 6c 20 32 3e 20 ll -9 fossil 2>
0260: 2f 64 65 76 2f 6e 75 6c 6c 0a 66 69 0a 0a 69 66 /dev/null.fi..if
0270: 20 5b 20 2d 78 20 2e 2f 66 6f 73 73 69 6c 20 5d [ -x ./fossil ]
0280: 0a 74 68 65 6e 0a 20 20 20 20 23 20 57 65 27 72 .then. # We'r
0290: 65 20 72 75 6e 6e 69 6e 67 20 66 72 6f 6d 20 61 e running from a
02a0: 20 62 75 69 6c 64 20 74 72 65 65 2c 20 73 6f 20 build tree, so
02b0: 75 73 65 20 74 68 61 74 20 76 65 72 73 69 6f 6e use that version
02c0: 20 69 6e 73 74 65 61 64 0a 20 20 20 20 46 4f 53 instead. FOS
02d0: 53 49 4c 3d 2e 2f 66 6f 73 73 69 6c 0a 66 69 0a SIL=./fossil.fi.
02e0: 0a 66 75 6e 63 74 69 6f 6e 20 73 74 61 72 74 5f .function start_
02f0: 6f 6e 65 28 29 20 7b 0a 20 20 20 20 62 6e 3d 24 one() {. bn=$
0300: 31 0a 20 20 20 20 6c 6e 3d 22 24 32 22 0a 0a 20 1. ln="$2"..
0310: 20 20 20 24 46 4f 53 53 49 4c 20 73 65 72 76 65 $FOSSIL serve
0320: 72 20 24 65 78 74 72 61 20 5c 0a 20 20 20 20 20 r $extra \.
0330: 20 20 20 2d 2d 73 63 67 69 20 5c 0a 20 20 20 20 --scgi \.
0340: 20 20 20 20 2d 2d 6c 6f 63 61 6c 68 6f 73 74 20 --localhost
0350: 5c 0a 20 20 20 20 20 20 20 20 2d 2d 70 6f 72 74 \. --port
0360: 20 24 50 4f 52 54 20 5c 0a 20 20 20 20 20 20 20 $PORT \.
0370: 20 2d 2d 6a 73 6d 6f 64 65 20 62 75 6e 64 6c 65 --jsmode bundle
0380: 64 20 5c 0a 20 20 20 20 20 20 20 20 2d 2d 62 61 d \. --ba
0390: 73 65 75 72 6c 20 24 7b 53 49 54 45 7d 2f 24 62 seurl ${SITE}/$b
03a0: 6e 20 5c 0a 20 20 20 20 20 20 20 20 2d 2d 65 72 n \. --er
03b0: 72 6f 72 6c 6f 67 20 7e 2f 6c 6f 67 2f 66 6f 73 rorlog ~/log/fos
03c0: 73 69 6c 2f 24 62 6e 2d 65 72 72 6f 72 73 2e 6c sil/$bn-errors.l
03d0: 6f 67 20 5c 0a 20 20 20 20 20 20 20 20 7e 2f 6d og \. ~/m
03e0: 75 73 65 75 6d 2f 24 62 6e 2e 66 6f 73 73 69 6c useum/$bn.fossil
03f0: 20 3e 20 7e 2f 6c 6f 67 2f 66 6f 73 73 69 6c 2f > ~/log/fossil/
0400: 24 62 6e 2d 73 74 64 6f 75 74 2e 6c 6f 67 20 26 $bn-stdout.log &
0410: 0a 20 20 20 20 65 63 68 6f 20 53 74 61 72 74 65 . echo Starte
0420: 64 20 24 6c 6e 20 46 6f 73 73 69 6c 20 73 65 72 d $ln Fossil ser
0430: 76 65 72 2c 20 70 6f 72 74 20 24 50 4f 52 54 2c ver, port $PORT,
0440: 20 50 49 44 20 24 21 2e 0a 20 20 20 20 50 4f 52 PID $!.. POR
0450: 54 3d 24 28 28 24 50 4f 52 54 20 2b 20 31 29 29 T=$(($PORT + 1))
0460: 0a 7d 0a 0a 73 74 61 72 74 5f 6f 6e 65 20 66 69 .}..start_one fi
0470: 72 73 74 20 20 22 46 69 72 73 74 20 50 72 6f 6a rst "First Proj
0480: 65 63 74 22 0a 73 74 61 72 74 5f 6f 6e 65 20 73 ect".start_one s
0490: 65 63 6f 6e 64 20 22 53 65 63 6f 6e 64 20 50 72 econd "Second Pr
04a0: 6f 6a 65 63 74 22 0a 73 74 61 72 74 5f 6f 6e 65 oject".start_one
04b0: 20 74 68 69 72 64 20 20 22 54 68 69 72 64 20 50 third "Third P
04c0: 72 6f 6a 65 63 74 22 0a roject".