Mercurial > hgrepos > hgweb.cgi > 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(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/s4-migrate.sh Sat Jun 13 20:26:36 2020 +0900 +++ b/s4-migrate.sh Sun Jun 14 08:47:48 2020 +0900 @@ -29,7 +29,7 @@ grp=`query "SELECT gname FROM main.grp WHERE rowid=$grid;"` htmlgrp=`echo "$grp"|htmlescape` qgrp=`sqlquote "$grp"` - if [ -n "`query 'SELECT gname FROM dst.grp WHERE gname=$qgrp;'`" ]; then + if [ -n "`query \"SELECT gname FROM dst.grp WHERE gname=$qgrp;\"`" ]; then echo "[$htmlgrp]グループがWorld[$htmlworld]にあるので中止します。"|html p failure=$((failure+1)) continue
--- a/s4-world.sh Sat Jun 13 20:26:36 2020 +0900 +++ b/s4-world.sh Sun Jun 14 08:47:48 2020 +0900 @@ -9,13 +9,14 @@ worldnamefile=cache/worldname if [ ! -e $worldlistfile -o $worldlistfile -ot s4-config.sh \ -o ! -e $worldoptionfile -o $worldoptionfile -ot s4-config.sh \ - -o s4-funcs.sh -nt $worldoptionfile ] + -o s4-world.sh -nt $worldoptionfile ] then echo S4MASTERURL=$S4MASTERURL >> tmp/debug.out cat <<-EOF > $worldlistfile - ${touchpanel:+ : }<div><table> + ${touchpanel:+ : ▼}<div><table> <tr><th>World List</th></tr> - <tr><td>⇒ <a href="${S4MASTERURL:-$URL}">Base</a></td></tr> + <tr><td title="Base World$nl拠点となるWorldです">⇒ + <a href="${S4MASTERURL:-$URL}">Base</a></td></tr> EOF true > $worldoptionfile for i in $S4WORLDLIST; do @@ -62,10 +63,19 @@ # sessdb=`dirname $S4MASTERDB`/sess.sq3 ## skey="skey-`basename $mydir`" syncflag=${db%.*}.synctime +runflag=${db%.*}.run userupdateflag=`dirname $S4MASTERDB`/`basename $userupdateflag` err SYNCFLAG=$syncflag test ! -e "$userupdateflag" && return test "$syncflag" -nt "$userupdateflag" && return +if [ -s "$runflag" ]; then + limit=`cat $runflag|tr -c -d 0-9` + if [ -n "$limit" -a "$limit" -gt `date +%s` ]; then + err "World $S4WORLD account sync withholded by process $$" + return # Running sync by other process not leaching timeout + fi +fi +echo $((`date +%s` + 10)) > $runflag # Setting running flag by timeout 10s # for sub.sq3 # @@ -76,9 +86,9 @@ # ## sqlite3 -cmd '.timer 1' -cmd '.echo 1' $db <<EOF -err "Starting account synchronization" -# num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF -cat > tmp/sql <<EOF +err "`gdate +%S.%3N` Starting account synchronization[$$]" +## cat > tmp/sql <<EOF +num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF ATTACH DATABASE "$S4MASTERDB" AS m; CREATE TABLE IF NOT EXISTS user(name, primary key(name)); BEGIN; @@ -110,15 +120,15 @@ ), a_m AS ( SELECT * FROM thisworld EXCEPT SELECT * FROM master ) SELECT (SELECT count(*) FROM m_a) + (SELECT count(*) FROM a_m); - --- SELECT * FROM thisworld; --- SELECT rowid,* FROM m.user LIMIT 10; --- SELECT rowid,* FROM user WHERE rowid NOT IN (SELECT rowid FROM m.user); DETACH DATABASE m; EOF -num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db < tmp/sql ) -if [ $num -eq 0 ]; then - touch $syncflag +) +### num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db < tmp/sql ) +if [ -n "$num" -a $num -eq 0 ]; then + err "`gdate +%S.%3N` Account synchronization[$$] done in difference $num" + echo "`date '+%F %T'`: Sync done by process $$" >> $syncflag +else + err "Account synch[$$] failed or bailed with num=[$num]" fi -err "Account synchronization done in difference $num" +test -e "$runflag" && rm -f "$runflag" return $num