Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-contained Example #10

Open
turbo opened this issue Jul 24, 2018 · 0 comments
Open

Self-contained Example #10

turbo opened this issue Jul 24, 2018 · 0 comments

Comments

@turbo
Copy link

turbo commented Jul 24, 2018

Hi,

A complete example of how to use this library would really help I think. I tried to set this up using lapis, but already failed at the config stage. Here's what I have so far:

app.moon

lapis = require "lapis"

rq = require "resty.qless"

ql = rq.new
  host: "127.0.0.1"
  port: 6379

class App extends lapis.Application    
  [index: "/"]: =>
    @html ->
      h1 "Hello!"
      p type ql

nginx.conf

worker_processes ${{NUM_WORKERS}};
error_log stderr notice;
daemon off;
pid logs/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include mime.types;

  server {
    listen ${{PORT}};
    lua_code_cache ${{CODE_CACHE}};

    location / {
      default_type text/html;
      content_by_lua '
        require("lapis").serve("app")
      ';
    }

    location /static/ {
      alias static/;
    }

    location /favicon.ico {
      alias static/favicon.ico;
    }
  }
}

That's it. Running the app crashes in the route with this message:

2018/07/24 13:42:06 [error] 23077#23077: *1 lua entry thread aborted: runtime error: attempt to yield across C-call boundary
stack traceback:
coroutine 0:
        [C]: in function 'require'
        /usr/local/share/lua/5.1/lapis/init.lua:15: in function 'serve'
        content_by_lua(nginx.conf.compiled:22):2: in function <content_by_lua(nginx.conf.compiled:22):1>, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant