s4
changeset 794:8448724f69e3 feature-world
Account sync-ing and migration fixed
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 14 Jun 2020 08:47:48 +0900 |
parents | 5d73f47cb1a9 |
children | 6164d88fbc0e |
files | s4-migrate.sh s4-world.sh |
diffstat | 2 files changed, 25 insertions(+), 12 deletions(-) [+] |
line diff
1.1 --- a/s4-migrate.sh Sat Jun 13 20:26:36 2020 +0900 1.2 +++ b/s4-migrate.sh Sun Jun 14 08:47:48 2020 +0900 1.3 @@ -29,7 +29,7 @@ 1.4 grp=`query "SELECT gname FROM main.grp WHERE rowid=$grid;"` 1.5 htmlgrp=`echo "$grp"|htmlescape` 1.6 qgrp=`sqlquote "$grp"` 1.7 - if [ -n "`query 'SELECT gname FROM dst.grp WHERE gname=$qgrp;'`" ]; then 1.8 + if [ -n "`query \"SELECT gname FROM dst.grp WHERE gname=$qgrp;\"`" ]; then 1.9 echo "[$htmlgrp]グループがWorld[$htmlworld]にあるので中止します。"|html p 1.10 failure=$((failure+1)) 1.11 continue
2.1 --- a/s4-world.sh Sat Jun 13 20:26:36 2020 +0900 2.2 +++ b/s4-world.sh Sun Jun 14 08:47:48 2020 +0900 2.3 @@ -9,13 +9,14 @@ 2.4 worldnamefile=cache/worldname 2.5 if [ ! -e $worldlistfile -o $worldlistfile -ot s4-config.sh \ 2.6 -o ! -e $worldoptionfile -o $worldoptionfile -ot s4-config.sh \ 2.7 - -o s4-funcs.sh -nt $worldoptionfile ] 2.8 + -o s4-world.sh -nt $worldoptionfile ] 2.9 then 2.10 echo S4MASTERURL=$S4MASTERURL >> tmp/debug.out 2.11 cat <<-EOF > $worldlistfile 2.12 - ${touchpanel:+ : }<div><table> 2.13 + ${touchpanel:+ : ▼}<div><table> 2.14 <tr><th>World List</th></tr> 2.15 - <tr><td>⇒ <a href="${S4MASTERURL:-$URL}">Base</a></td></tr> 2.16 + <tr><td title="Base World$nl拠点となるWorldです">⇒ 2.17 + <a href="${S4MASTERURL:-$URL}">Base</a></td></tr> 2.18 EOF 2.19 true > $worldoptionfile 2.20 for i in $S4WORLDLIST; do 2.21 @@ -62,10 +63,19 @@ 2.22 # sessdb=`dirname $S4MASTERDB`/sess.sq3 2.23 ## skey="skey-`basename $mydir`" 2.24 syncflag=${db%.*}.synctime 2.25 +runflag=${db%.*}.run 2.26 userupdateflag=`dirname $S4MASTERDB`/`basename $userupdateflag` 2.27 err SYNCFLAG=$syncflag 2.28 test ! -e "$userupdateflag" && return 2.29 test "$syncflag" -nt "$userupdateflag" && return 2.30 +if [ -s "$runflag" ]; then 2.31 + limit=`cat $runflag|tr -c -d 0-9` 2.32 + if [ -n "$limit" -a "$limit" -gt `date +%s` ]; then 2.33 + err "World $S4WORLD account sync withholded by process $$" 2.34 + return # Running sync by other process not leaching timeout 2.35 + fi 2.36 +fi 2.37 +echo $((`date +%s` + 10)) > $runflag # Setting running flag by timeout 10s 2.38 2.39 # for sub.sq3 2.40 # 2.41 @@ -76,9 +86,9 @@ 2.42 # 2.43 2.44 ## sqlite3 -cmd '.timer 1' -cmd '.echo 1' $db <<EOF 2.45 -err "Starting account synchronization" 2.46 -# num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF 2.47 -cat > tmp/sql <<EOF 2.48 +err "`gdate +%S.%3N` Starting account synchronization[$$]" 2.49 +## cat > tmp/sql <<EOF 2.50 +num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF 2.51 ATTACH DATABASE "$S4MASTERDB" AS m; 2.52 CREATE TABLE IF NOT EXISTS user(name, primary key(name)); 2.53 BEGIN; 2.54 @@ -110,15 +120,15 @@ 2.55 ), a_m AS ( 2.56 SELECT * FROM thisworld EXCEPT SELECT * FROM master 2.57 ) SELECT (SELECT count(*) FROM m_a) + (SELECT count(*) FROM a_m); 2.58 - 2.59 --- SELECT * FROM thisworld; 2.60 --- SELECT rowid,* FROM m.user LIMIT 10; 2.61 --- SELECT rowid,* FROM user WHERE rowid NOT IN (SELECT rowid FROM m.user); 2.62 DETACH DATABASE m; 2.63 EOF 2.64 -num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db < tmp/sql ) 2.65 -if [ $num -eq 0 ]; then 2.66 - touch $syncflag 2.67 +) 2.68 +### num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db < tmp/sql ) 2.69 +if [ -n "$num" -a $num -eq 0 ]; then 2.70 + err "`gdate +%S.%3N` Account synchronization[$$] done in difference $num" 2.71 + echo "`date '+%F %T'`: Sync done by process $$" >> $syncflag 2.72 +else 2.73 + err "Account synch[$$] failed or bailed with num=[$num]" 2.74 fi 2.75 -err "Account synchronization done in difference $num" 2.76 +test -e "$runflag" && rm -f "$runflag" 2.77 return $num