Mercurial Hosting > luan
annotate examples/blog/src/lib/Db.luan @ 1692:d6ec67fa4a61
tools for config files
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 14 Jun 2022 21:59:39 -0600 |
parents | 8dd8c556c449 |
children | 2958cf04d844 |
rev | line source |
---|---|
1396
a5f61890ad84
add check_postgres_password
Franklin Schmidt <fschmidt@gmail.com>
parents:
1395
diff
changeset
|
1 local Luan = require "luan:Luan.luan" |
a5f61890ad84
add check_postgres_password
Franklin Schmidt <fschmidt@gmail.com>
parents:
1395
diff
changeset
|
2 local error = Luan.error |
a5f61890ad84
add check_postgres_password
Franklin Schmidt <fschmidt@gmail.com>
parents:
1395
diff
changeset
|
3 local stringify = Luan.stringify or error() |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
4 local Lucene = require "luan:lucene/Lucene.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
5 local Io = require "luan:Io.luan" |
1672 | 6 local uri = Io.uri or error() |
1399 | 7 local Time = require "luan:Time.luan" |
8 local Thread = require "luan:Thread.luan" | |
1672 | 9 local Hosted = require "luan:host/Hosted.luan" |
1392 | 10 local Logging = require "luan:logging/Logging.luan" |
11 local logger = Logging.logger "Db" | |
596 | 12 |
13 | |
1672 | 14 if not Hosted.is_hosted then |
15 require "java" | |
16 local BackupIndexWriter = require "java:goodjava.lucene.backup.BackupIndexWriter" | |
17 BackupIndexWriter.backupDomains = {"localhost"} | |
18 end | |
19 | |
20 --local postgres_spec = Hosted.postgres_spec() | |
1396
a5f61890ad84
add check_postgres_password
Franklin Schmidt <fschmidt@gmail.com>
parents:
1395
diff
changeset
|
21 --logger.info(stringify(postgres_spec)) |
1395
9dfff82dfc59
finish postgres work
Franklin Schmidt <fschmidt@gmail.com>
parents:
1393
diff
changeset
|
22 |
1672 | 23 local dir = uri("site:/private/local/lucene") |
1429
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
24 local Db = Lucene.index( dir, { |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
25 default_type = Lucene.type.english |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
26 default_fields = {"subject","content"} |
1672 | 27 --postgres_spec = postgres_spec |
28 log_dir = uri("site:/private/local/lucene_log") | |
1429
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
29 } ) |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
30 |
596 | 31 -- this is how you index a field |
32 -- db.indexed_fields.post_date = Lucene.type.long | |
33 | |
1672 | 34 --Db.restore_from_postgres() |
35 Db.restore_from_log() | |
1429
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
36 Db.update{ |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
37 [1] = function() |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
38 logger.info "update" |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
39 end |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
40 } |
82415c9c0015
move versioning into Lucene
Franklin Schmidt <fschmidt@gmail.com>
parents:
1418
diff
changeset
|
41 Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1}, id="blog-db-check" } ) |
1399 | 42 |
1220 | 43 return Db |