mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-10 03:42:56 +08:00
Change syncer.SyncInterval to second-level.
This commit is contained in:
2
go.mod
2
go.mod
@@ -18,9 +18,9 @@ require (
|
|||||||
github.com/google/uuid v1.2.0
|
github.com/google/uuid v1.2.0
|
||||||
github.com/jinzhu/configor v1.2.1 // indirect
|
github.com/jinzhu/configor v1.2.1 // indirect
|
||||||
github.com/markbates/goth v1.68.1-0.20211006204042-9dc8905b41c8
|
github.com/markbates/goth v1.68.1-0.20211006204042-9dc8905b41c8
|
||||||
github.com/mileusna/crontab v1.0.1
|
|
||||||
github.com/qiangmzsx/string-adapter/v2 v2.1.0
|
github.com/qiangmzsx/string-adapter/v2 v2.1.0
|
||||||
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76
|
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76
|
||||||
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/russellhaering/gosaml2 v0.6.0
|
github.com/russellhaering/gosaml2 v0.6.0
|
||||||
github.com/russellhaering/goxmldsig v1.1.1
|
github.com/russellhaering/goxmldsig v1.1.1
|
||||||
github.com/satori/go.uuid v1.2.0 // indirect
|
github.com/satori/go.uuid v1.2.0 // indirect
|
||||||
|
4
go.sum
4
go.sum
@@ -264,8 +264,6 @@ github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJK
|
|||||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/mileusna/crontab v1.0.1 h1:YrDLc7l3xOiznmXq2FtAgg+1YQ3yC6pfFVPe+ywXNtg=
|
|
||||||
github.com/mileusna/crontab v1.0.1/go.mod h1:dbns64w/u3tUnGZGf8pAa76ZqOfeBX4olW4U1ZwExmc=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -313,6 +311,8 @@ github.com/qiangmzsx/string-adapter/v2 v2.1.0 h1:q0y8TPa/sTwtriJPRe8gWL++PuZ+XbO
|
|||||||
github.com/qiangmzsx/string-adapter/v2 v2.1.0/go.mod h1:PElPB7b7HnGKTsuADAffFpOQXHqjEGJz1+U1a6yR5wA=
|
github.com/qiangmzsx/string-adapter/v2 v2.1.0/go.mod h1:PElPB7b7HnGKTsuADAffFpOQXHqjEGJz1+U1a6yR5wA=
|
||||||
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76 h1:J2Xj92efYLxPl3BiibgEDEUiMsCBzwTurE/8JjD8CG4=
|
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76 h1:J2Xj92efYLxPl3BiibgEDEUiMsCBzwTurE/8JjD8CG4=
|
||||||
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76/go.mod h1:JhtPzUhP5KGtCB2yksmxuYAD4hEWw4qGQJpucjsm3U0=
|
github.com/qor/oss v0.0.0-20191031055114-aef9ba66bf76/go.mod h1:JhtPzUhP5KGtCB2yksmxuYAD4hEWw4qGQJpucjsm3U0=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||||
|
@@ -14,27 +14,27 @@
|
|||||||
|
|
||||||
package object
|
package object
|
||||||
|
|
||||||
import "github.com/mileusna/crontab"
|
import "github.com/robfig/cron/v3"
|
||||||
|
|
||||||
var cronMap map[string]*crontab.Crontab
|
var cronMap map[string]*cron.Cron
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cronMap = map[string]*crontab.Crontab{}
|
cronMap = map[string]*cron.Cron{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCrontab(name string) *crontab.Crontab {
|
func getCronMap(name string) *cron.Cron {
|
||||||
ctab, ok := cronMap[name]
|
m, ok := cronMap[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
ctab = crontab.New()
|
m = cron.New()
|
||||||
cronMap[name] = ctab
|
cronMap[name] = m
|
||||||
}
|
}
|
||||||
return ctab
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func clearCrontab(name string) {
|
func clearCron(name string) {
|
||||||
ctab, ok := cronMap[name]
|
cron, ok := cronMap[name]
|
||||||
if ok {
|
if ok {
|
||||||
ctab.Clear()
|
cron.Stop()
|
||||||
delete(cronMap, name)
|
delete(cronMap, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -166,14 +166,14 @@ func RunSyncUsersJob() {
|
|||||||
|
|
||||||
syncer.syncUsers()
|
syncer.syncUsers()
|
||||||
|
|
||||||
// run at every minute
|
schedule := fmt.Sprintf("@every %ds", syncer.SyncInterval)
|
||||||
//schedule := fmt.Sprintf("* * * * %d", syncer.SyncInterval)
|
cron := getCronMap(syncer.Name)
|
||||||
schedule := "* * * * *"
|
_, err := cron.AddFunc(schedule, syncer.syncUsers)
|
||||||
ctab := getCrontab(syncer.Name)
|
|
||||||
err := ctab.AddJob(schedule, syncer.syncUsers)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cron.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(time.Duration(1<<63 - 1))
|
time.Sleep(time.Duration(1<<63 - 1))
|
||||||
|
@@ -41,7 +41,7 @@ class SyncerListPage extends BaseListPage {
|
|||||||
tableColumns: [],
|
tableColumns: [],
|
||||||
affiliationTable: "",
|
affiliationTable: "",
|
||||||
avatarBaseUrl: "",
|
avatarBaseUrl: "",
|
||||||
syncInterval: 1,
|
syncInterval: 10,
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -388,7 +388,7 @@
|
|||||||
"Edit Syncer": "编辑同步器",
|
"Edit Syncer": "编辑同步器",
|
||||||
"Is hashed": "是否参与哈希计算",
|
"Is hashed": "是否参与哈希计算",
|
||||||
"Sync interval": "同步间隔",
|
"Sync interval": "同步间隔",
|
||||||
"Sync interval - Tooltip": "单位为分钟",
|
"Sync interval - Tooltip": "单位为秒",
|
||||||
"Table": "表名",
|
"Table": "表名",
|
||||||
"Table - Tooltip": "数据库表名",
|
"Table - Tooltip": "数据库表名",
|
||||||
"Table columns": "表格列",
|
"Table columns": "表格列",
|
||||||
|
Reference in New Issue
Block a user