Closed katsifolis closed 2 years ago
Do you have anything that might be overriding the environment name, like lapis_environment.lua
or the LAPIS_ENVIRONMENT
environment variable set?
What does the first line of nginx.conf.compiled
say? It should have a line that shows the environment name
This doesn't seem to be an environment error because the first line of conf.compiled gets changed if I pass a name other than production.
config.moon
-- config.moon import config from require "lapis.config" config "production", -> port 8001 num_workers 4 code_cache "on"
config "dev", -> port 8081 num_workers 1 code_cache "on"
cat nginx.conf.compiled env LAPIS_ENVIRONMENT=production; worker_processes 4; error_log stderr notice; daemon off; pid logs/nginx.pid;
events { worker_connections 1024; }
http { include mime.types; lua_package_path "./?.lua;;";
server { listen 8080; lua_code_cache off;
location / {
default_type text/html;
content_by_lua_block {
require("lapis").serve("app")
}
}
location /static/ {
alias static/;
}
location /favicon.ico {
alias static/favicon.ico;
}
} }
cat nginx.conf.compiled env LAPIS_ENVIRONMENT=dev; worker_processes 4; error_log stderr notice; daemon off; pid logs/nginx.pid;
events { worker_connections 1024; }
http { include mime.types; lua_package_path "./?.lua;;";
server { listen 8080; lua_code_cache off;
location / {
default_type text/html;
content_by_lua_block {
require("lapis").serve("app")
}
}
location /static/ {
alias static/;
}
location /favicon.ico {
alias static/favicon.ico;
}
} }
Are you sure your port is a variable on the source nginx.conf
?
Also did you compile your moon files?
Yeah it is ..
worker_processes 4;
error_log stderr notice;
daemon off;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
lua_package_path "./?.lua;;";
server {
listen ${{PORT}};
lua_code_cache ${{CODE_CACHE}};
location / {
default_type text/html;
content_by_lua_block {
require("lapis").serve("app")
}
}
location /static/ {
alias static/;
}
location /favicon.ico {
alias static/favicon.ico;
}
}
}
Sure I am running tup..
Can you double check that config.lua
exists in the folder where you're running the lapis
command, and the contents reflect the correct details
Yeap I checked and it looks like this.
local config
config = require("lapis.config").config
config("production", function()
port(8001)
num_workers(4)
code_cache("on")
end)
return config("dev", function()
port(8081)
num_workers(1)
code_cache("off")
end)
does running LAPIS_ENVIRONMENT=production lapis server
do what you expect?
No it just bypasses it.
Well, I'm probably at the end of helping you debug it. There's something about your environment that is changing how it works, or something you're missing (typo, file you didn't notice, something not compiled, lua code path, etc.). Environment selection is working as expected on our test suite and in all severs I'm using it in.
You might also want to check you're running the latest version of lapis.
You can then try uninstalling it, then removing all traces of lapis from the luarocks install directory to make sure you're getting clean install.
Okay thanks a lot for your insight. I will try to reinstall in a fresh environment!
I have this problem with lapis
when i run
lapis server production
there is no modification in nginx.conf.compiled whatsoever so the port doesn't change nor the code_cache. However the server runs normally under :8080