Code Monkey home page Code Monkey logo

Comments (12)

leafo avatar leafo commented on May 28, 2024

Can I see what your config looks like?

from lapis.

jlebrech avatar jlebrech commented on May 28, 2024
worker_processes  ${{NUM_WORKERS}};
error_log stderr notice;
daemon off;
env LAPIS_ENVIRONMENT;

events {
  worker_connections 1024;
}

http {
  include mime.types;

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

    location / {
      default_type text/html;
      set $_url "";
      content_by_lua_file "web.lua";
    }

    location /static/ {
      alias static/;
    }

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

    location = /query {
      internal;
      postgres_pass database;
      postgres_query $echo_request_body;
    }
  }

  upstream database {
    postgres_server ${{pg POSTGRESQL_URL}};
  }
}

from lapis.

killercup avatar killercup commented on May 28, 2024

I'm fairly certain you need to create a config.moon file which contains the value for ${{pg POSTGRESQL_URL}}. It was one of the first obstacles I ran into as well. (It's documented but for some reason I missed it.)

-- config.moon
import config from require "lapis.config"

config "development", ->
  port 8080
  postgresql_url "postgres://user:pass@host/dbname"

from lapis.

jlebrech avatar jlebrech commented on May 28, 2024

My config.moon looks like this:

import config from require "lapis.config"

config "development", ->
  postgresql_url "postgres:://jlebrech:127.0.0.1/mydatabase"

So I'm not sure this is where the problem lies.

from lapis.

killercup avatar killercup commented on May 28, 2024

(FYI, there is a double colon in postgres:://.)

from lapis.

jlebrech avatar jlebrech commented on May 28, 2024

The error message is unrelated to the double " but thanks for noticing

from lapis.

leafo avatar leafo commented on May 28, 2024

I think the double colon is the problem. The error message you are getting is because the compiled config has a blank string as the postgres url in the upstream block. This is because your postgres url is improperly formed and couldn't be parsed. I'll update the code to produce a better error message.

from lapis.

jlebrech avatar jlebrech commented on May 28, 2024

I fixed the string to not have a double colon, so it's not that particular
thing but maybe my string is still wrong.
On May 2, 2013 7:42 PM, "leaf" [email protected] wrote:

I think the double colon is the problem. The error message you are getting
is because the compiled config has a blank string as the postgres url in
the upstream block. This is because your postgres url is improperly formed
and couldn't be parsed. I'll update the code to produce a better error
message.


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-17356344
.

from lapis.

leafo avatar leafo commented on May 28, 2024

Ah I see now, there is a typo in the docs. The correct format for the db string is:

config "development", ->
  postgresql_url "postgres://pg_user:[email protected]/my_database"

from lapis.

jlebrech avatar jlebrech commented on May 28, 2024

here's my "app" https://github.com/jlebrech/mylapisapp

I still get a warning about this

directive "postgres_server" is not terminated by ";" in /Users/jlebrech/mylapisapp/nginx.conf.compiled:39

from lapis.

leafo avatar leafo commented on May 28, 2024

It looks like you didn't compile the config file from moon to lua, so configuration is not being loaded and set.

There are a few things I can do to make this better. First I can just throw an error when an variable that isn't set is being used in the config syntax. So you don't get difficult to debug errors from Nginx.

Secondly, the Lapis runtime doesn't depend on MoonScript but I can make it detect if MoonScript is installed and load the config.moon file if the Lua equivalent isn't there. I still think it's probably best to compile it though because if you deploy just Lua files to another server it might not have MoonScript.

For now, just run moonc . in the current directory and the server should start.

from lapis.

jlebrech avatar jlebrech commented on May 28, 2024

damn, that fixed it.

It's funny because when I delete the lua file it compiles for me, I just
assumed it was doing that.

On Sat, May 4, 2013 at 4:56 PM, leaf [email protected] wrote:

It looks like you didn't compile the config file from moon to lua, so
configuration is not being loaded and set.

There are a few things I can do to make this better. First I can just
throw an error when an variable that isn't set is being used in the config
syntax. So you don't get difficult to debug errors from Nginx.

Secondly, the Lapis runtime doesn't depend on MoonScript but I can make it
detect if MoonScript is installed and load the config.moon file if the
Lua equivalent isn't there. I still think it's probably best to compile it
though because if you deploy just Lua files to another server it might not
have MoonScript.

For now, just run moonc . in the current directory and the server should
start.


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-17436496
.

from lapis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.