Closed kwccoin closed 4 years ago
Hm what happens when you run it with the DATABASE_URL
environment variable set?
DATABASE_URL=path-to-your-db.sqlite3 joy server
Try it and get pass the stage where joy sever can be started
joy server Server listening on [localhost:8000] ... [2020-05-03 05:24:59] at=info msg="Started GET /" method=GET url=/ [2020-05-03 05:24:59] at=info msg="Finished GET /" method=GET url=/ status=200 duration=0.0026ms content-type=text/html [2020-05-03 05:24:59] at=info msg="Started GET /favicon.ico" method=GET url=/favicon.ico
But the database seems not sure. I did something but obvious have problem.
' joy create table account 'email text not null uniqu 'password text not null''
create those directory and files i.e.
'ls db/migrations/ 20200503052212-create-table-account.sql'
But
'joy migrate
error: file is not a database
in sqlite3/eval
in execute [/usr/local/Cellar/janet/1.8.1/lib/janet/db/sqlite/db.janet] on line 90, column 5
in
I drop the db and create the db again; then I remember there is this message that appear again:
joy create db error: bad slot #0, expected core/file, got nil in file/close in create-file [/usr/local/Cellar/janet/1.8.1/lib/janet/joy/helper.janet] (tailcall) on line 143, column 3
Not sure how to move on.
Just in case, may I ask seem you seems to know janet well -- is all these can be done in an embedded environment like picolisp (which I like but only run under certain env.)
the file structure seems already btw:
ls Procfile main.janet src db project.janet test development.sqlite3 public watch
Just somehow somewhere the 'joy create db' is not working for me.
So it was bad timing on my part, I switched the database code to the db
library (for postgres support) but I didn't update the files generated from joy new
so there's an old version of joy 0.6.0
in the generated project.janet
I pushed some changes and tagged them version 0.7.3
the changes are on line 25 in server.janet
:
(db/connect (env :database-url))
so you don't have to pass DATABASE_URL
You could also install the latest version of joy by changing the project.janet
to look like this:
(declare-project
:name "%project-name%"
:description ""
:dependencies ["https://github.com/joy-framework/joy"]
:author ""
:license ""
:url ""
:repo "")
(declare-executable
:name "%project-name%"
:entry "main.janet")
(phony "server" []
(do
(os/shell "pkill -xf 'janet main.janet'")
(os/shell "janet main.janet")))
(phony "watch" []
(do
(os/shell "pkill -xf 'janet main.janet'")
(os/shell "janet main.janet &")
(os/shell "fswatch -o src | xargs -n1 -I{} ./watch")))
The main change:
- :dependencies [{:repo "https://github.com/joy-framework/joy" :tag "0.6.0"}
- "https://github.com/joy-framework/tester"]
+ :dependencies ["https://github.com/joy-framework/joy"]
and then run jpm deps
to install the latest joy
Thanks. Would try it tomorrow. Quite late here.
All can be done now. Great.
I will study a bit the db part. Seems job create db and doing something there but not sure what. got schema, got ... just no actual db records. Strange. But I guess I just have to close the case and study more about this.
after finding joy, I tried based on sample script here but failed with:
joy server error: DATABASE_URL environment variable isn't set in connect [/usr/local/Cellar/janet/1.8.1/lib/janet/db/sqlite/db.janet] on line 10, column 5 in start [src/server.janet] (tailcall) on line 25, column 5 in _thunk [main.janet] on line -1, column -1 in cli-main [boot.janet] on line 2446, column 35
I persist and whilst the db creation all ok, it is obviously not working and the final to do joy server every command. This is the final output:
joy server error: could not find module joy/db: /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db.jimage /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db.janet /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db/init.janet /usr/local/Cellar/janet/1.8.1/lib/janet/joy/db.so joy/db.jimage joy/db.janet joy/db/init.janet joy/db.so in require [boot.janet] on line 2211, column 20 in import* [boot.janet] on line 2229, column 15 in _thunk [src/routes/account.janet] (tailcall) on line 2, column 1 error: DATABASE_URL environment variable isn't set in connect [/usr/local/Cellar/janet/1.8.1/lib/janet/db/sqlite/db.janet] on line 10, column 5 in start [src/server.janet] (tailcall) on line 25, column 5 in _thunk [main.janet] on line -1, column -1 in cli-main [boot.janet] on line 2446, column 35
Any further help?