summaryrefslogtreecommitdiff
path: root/datomic-pro-1.0.7469/create-db.bsh
blob: e70851beb7682177c45307e493ac3765f8780a85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
db_name = System.getenv("DATOMIC_DB");
if (db_name == null || db_name.isEmpty()) {
   db_name = "app";
}
db_uri = "datomic:sql://" + db_name + "?jdbc:sqlite:/usr/storage/sqlite.db";
for (int i = 0; i < 20; i++) {
    Thread.sleep(3000);
    System.out.println("Testing connection to database '" + db_name + "'...");
    try {
        if (Peer.createDatabase(db_uri)) {
            System.out.println("Created database '" + db_name + "'");
        }
        try {
            new File("/usr/datomic-pro/db_ready").createNewFile();
        } catch (Exception e) {
            System.out.println("Could not create file /usr/datomic-pro/db_ready: " + e.getMessage());
        }
        System.out.println("Connect using DB URI datomic:sql://" + db_name + "?jdbc:sqlite:<LOCAL/PATH/TO/sqlite.db>");
        System.out.println("  e.g. datomic:sql://app?jdbc:sqlite:./storage/sqlite.db if you mounted ./storage");
        System.exit(0);
    } catch (Exception e) {
        // System.out.println(e.getMessage());
    }
}
System.out.println("WARNING: Could not create or connect to database " + db_name + " after 10s.");