Mercurial Hosting > luan
comparison examples/blog/src/lib/Db.luan @ 1672:8dd8c556c449
backup work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 26 May 2022 21:10:02 -0600 |
parents | 13135e289b50 |
children | 2958cf04d844 |
comparison
equal
deleted
inserted
replaced
1671:8066b8882732 | 1672:8dd8c556c449 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local stringify = Luan.stringify or error() | 3 local stringify = Luan.stringify or error() |
4 local Lucene = require "luan:lucene/Lucene.luan" | 4 local Lucene = require "luan:lucene/Lucene.luan" |
5 local Io = require "luan:Io.luan" | 5 local Io = require "luan:Io.luan" |
6 local Hosted = require "luan:host/Hosted.luan" | 6 local uri = Io.uri or error() |
7 local Time = require "luan:Time.luan" | 7 local Time = require "luan:Time.luan" |
8 local Thread = require "luan:Thread.luan" | 8 local Thread = require "luan:Thread.luan" |
9 local Hosted = require "luan:host/Hosted.luan" | |
9 local Logging = require "luan:logging/Logging.luan" | 10 local Logging = require "luan:logging/Logging.luan" |
10 local logger = Logging.logger "Db" | 11 local logger = Logging.logger "Db" |
11 | 12 |
12 | 13 |
13 local postgres_spec = Hosted.postgres_spec() | 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() | |
14 --logger.info(stringify(postgres_spec)) | 21 --logger.info(stringify(postgres_spec)) |
15 | 22 |
16 local dir = Io.uri("site:/private/local/lucene") | 23 local dir = uri("site:/private/local/lucene") |
17 local Db = Lucene.index( dir, { | 24 local Db = Lucene.index( dir, { |
18 default_type = Lucene.type.english | 25 default_type = Lucene.type.english |
19 default_fields = {"subject","content"} | 26 default_fields = {"subject","content"} |
20 postgres_spec = postgres_spec | 27 --postgres_spec = postgres_spec |
28 log_dir = uri("site:/private/local/lucene_log") | |
21 } ) | 29 } ) |
22 | 30 |
23 -- this is how you index a field | 31 -- this is how you index a field |
24 -- db.indexed_fields.post_date = Lucene.type.long | 32 -- db.indexed_fields.post_date = Lucene.type.long |
25 | 33 |
26 Db.restore_from_postgres() | 34 --Db.restore_from_postgres() |
35 Db.restore_from_log() | |
27 Db.update{ | 36 Db.update{ |
28 [1] = function() | 37 [1] = function() |
29 logger.info "update" | 38 logger.info "update" |
30 end | 39 end |
31 } | 40 } |