i already install luasocket
Lua 5.3.1 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> require("socket.http")
table: 0x9b2d80
>
debian:/usr/local/share/lua/5.3/socket# ll
total 56
-rw-r--r-- 1 root root 10640 Dec 22 17:47 ftp.lua
-rw-r--r-- 1 root root 3698 Dec 22 17:47 headers.lua
-rw-r--r-- 1 root root 13216 Dec 22 17:47 http.lua
-rw-r--r-- 1 root root 8074 Dec 22 17:47 smtp.lua
-rw-r--r-- 1 root root 3766 Dec 22 17:47 tp.lua
-rw-r--r-- 1 root root 11105 Dec 22 17:47 url.lua
in Haproxy Lua code:
local http = require("socket.http")
When i request web,
runtime error: /etc/haproxy/waf/lib.lua:7: module 'socket.http' not found:#012#011no field package.preload['socket.http']#012#011no file '/usr/local/share/lua/5.3/socket/http.lua'#012#011no file '/usr/local/share/lua/5.3/socket/http/init.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http/init.lua'#012#011no file '/usr/share/lua/5.3/socket/http.lua'#012#011no file '/usr/share/lua/5.3/socket/http/init.lua'#012#011no file './socket/http.lua'#012#011no file './socket/http/init.lua'#012#011no file '/etc/haproxy/waf/socket/http.lua'#012#011no file '/etc/haproxy/waf/socket/http.lua'#012#011no file '/usr/local/lib/lua/5.3/socket/http.so'#012#011no file '/usr/lib/x86_64-linux-gnu/lua/5.3/socket/http.so'#012#011no file '/usr/lib/lua/5.3/socket/http.so'#012#011no file '/usr/local/lib/lua/5.3/loadall.so'#012#011no file './socket/http.so'#012#011no file '/usr/local/lib/lua/5.3/socket.so'#012#011no file '/usr/lib/x86_64-linux-gnu/lua/5.3/socket.so'#012#011no file '/usr/lib/lua/5.3/socket.so'#012#011no file '/usr/lo
who can help me. thx
Your computer cannot find the required files.
https://www.lua.org/pil/8.1.html
To determine its path, require first checks the global variable
LUA_PATH. If the value of LUA_PATH is a string, that string is the
path. Otherwise, require checks the environment variable LUA_PATH.
Finally, if both checks fail, require uses a fixed path (typically
"?;?.lua", although it is easy to change that when you compile Lua).
The content of LUA_PATH will be copied into package.path. So either add the location of that module to the system variable befor running Lua or add it to package.path befor require.
Related
Wherever I see flake-compat used, it is a variation of
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).shellNix
It is obviously a path that refers to the current directory which can be proven with a simple test:
[~/testdir]$ ll .
total 24
drwxr-xr-x 2 toraritte users 4096 Jul 21 21:56 ./
drwx------ 7 toraritte users 20480 Jul 15 23:13 ../
-rw-r--r-- 1 toraritte users 0 Jul 21 21:56 lofa
[~/testdir]$ ll ./.
total 24
drwxr-xr-x 2 toraritte users 4096 Jul 21 21:56 ./
drwx------ 7 toraritte users 20480 Jul 15 23:13 ../
-rw-r--r-- 1 toraritte users 0 Jul 21 21:56 lofa
So why not simply use .?
From 5.2.1 Values section of the Nix manual (emphasis mine):
Paths, e.g., /bin/sh or ./builder.sh. A path must contain at least one
slash to be recognised as such.
For instance, builder.sh is not a
path: it's parsed as an expression that selects the attribute sh from
the variable builder. If the file name is relative, i.e., if it does
not begin with a slash, it is made absolute at parse time relative to
the directory of the Nix expression that contained it. For instance,
if a Nix expression in /foo/bar/bla.nix refers to ../xyzzy/fnord.nix,
the absolute path is /foo/xyzzy/fnord.nix.
i'm trying to run a lua script from inside haproxy that imports the "pgmoon" library. i can import pgmoon and get as far as opening a socket, but then i run into this:
[ALERT] 082/234313 (8) : Lua function 'queue-request': runtime error: /usr/local/share/lua/5.3/pgmoon/init.lua:269: module 'pgmoon.crypto' not found:
no field package.preload['pgmoon.crypto']
no file '/usr/local/share/lua/5.3/pgmoon/crypto.lua'
no file '/usr/local/share/lua/5.3/pgmoon/crypto/init.lua'
no file '/usr/local/lib/lua/5.3/pgmoon/crypto.lua'
no file '/usr/local/lib/lua/5.3/pgmoon/crypto/init.lua'
no file '/usr/share/lua/5.3/pgmoon/crypto.lua'
no file '/usr/share/lua/5.3/pgmoon/crypto/init.lua'
no file './pgmoon/crypto.lua'
no file './pgmoon/crypto/init.lua'
no file '/usr/local/lib/lua/5.3/pgmoon/crypto.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.3/pgmoon/crypto.so'
no file '/usr/lib/lua/5.3/pgmoon/crypto.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './pgmoon/crypto.so'
no file '/usr/local/lib/lua/5.3/pgmoon.so'
no file '/usr/lib/x86_64-linux-gnu/lua/5.3/pgmoon.so'
no file '/usr/lib/lua/5.3/pgmoon.so'
no file '/usr/local/lib/lua/5.3/loadall.so'
no file './pgmoon.so' from [C] global 'require', /usr/local/share/lua/5.3/pgmoon/init.lua:269 C function line 267 ..., /usr/local/share/lua/5.3/pgmoon/init.lua:211 method 'connect', /usr/local/haproxy/queue-request.lua:38 C function line 25.
however, there is a file at /usr/local/share/lua/5.3/pgmoon/crypto.lua, this is what ls shows:
# ls -la /usr/local/share/lua/5.3/pgmoon/
total 60
drwxr-xr-x 1 root root 4096 Mar 24 23:42 .
drwxr-xr-x 1 root root 4096 Mar 24 23:00 ..
-rw-r--r-- 1 root root 2880 Mar 24 23:00 arrays.lua
-rw-r--r-- 1 root root 1130 Mar 24 23:00 bit.lua
-rw-r--r-- 1 root root 1587 Mar 24 23:00 cqueues.lua
-rw-r--r-- 1 root root 654 Mar 24 23:00 crypto.lua
-rw-r--r-- 1 root root 2084 Mar 24 23:00 hstore.lua
-rw-r--r-- 1 root root 20127 Mar 24 23:00 init.lua
-rw-r--r-- 1 root root 665 Mar 24 23:00 json.lua
-rw-r--r-- 1 root root 2728 Mar 24 23:42 socket.lua
-rw-r--r-- 1 root root 457 Mar 24 23:00 util.lua
i could see it being permissions-related, if the haproxy user couldn't access a root owned file, but by the time it gets here it's already executed init.lua which has imported socket.lua and they've all got the same permissions...
Anybody know why lua thinks there is no file at crypto.lua?
I guess that you have haproxy configured with chroot and there actually isn't a file at /usr/local/share/lua/5.3/pgmoon/crypto.lua - in the chroot you haproxy runs in.
The require('pgmoon.crypto') in init.lua is within a function and probably tries to run long after Haproxy and lua initialization - and the root change.
And somewhat (un)relatedly - you can probably expect other problems with the pgmoon not being aware of haproxy, eg. its use of luasocket and not the haproxy-provided replacement: https://www.haproxy.com/blog/5-ways-to-extend-haproxy-with-lua/
The Socket class is a replacement for the standard Lua Socket class and is compatible with HAProxy’s non-blocking nature. When you want to use socket functions in your actions, you must use this class.
I have installed HAProxy with Lua 5.3.1, and also LuaSocket.
I have LUA_PATH and LUA_CPATH defined:
export LUA_PATH="/usr/local/share/lua/5.3/?.lua;?.lua"
export LUA_CPATH="/usr/local/lib/lua/5.3/?.so;?.so"
and I'm using LuaSocket in my .lua file
core.register_fetches("myfunc", function(txn)
...
local http = require("socket.http")
r, e = http.request("http://localhost:5001/api/Registry/")
however I can see from journalctl -xe that it isn't working
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: [ALERT] 344/232733 (16734) : Lua sample-fetch 'myfunc': runtime error: /home/ubuntu/haproxy-mapping.lua:12: module 'socket.http' not found:
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no field package.preload['socket.http']
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/share/lua/5.3/socket/http.lua'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/share/lua/5.3/socket/http/init.lua'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/lib/lua/5.3/socket/http.lua'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/lib/lua/5.3/socket/http/init.lua'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file './socket/http.lua'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file './socket/http/init.lua'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/lib/lua/5.3/socket/http.so'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/lib/lua/5.3/loadall.so'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file './socket/http.so'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/lib/lua/5.3/socket.so'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file '/usr/local/lib/lua/5.3/loadall.so'
Dec 11 23:27:33 ip-172-31-5-92 haproxy[16731]: no file './socket.so' from [C] global 'require', /home/ubuntu/haproxy-mapping.lua:12 C function line 4.
I'm surprised that it cannot find /usr/local/share/lua/5.3/socket/http.lua because it's there:
me$ ls -l /usr/local/share/lua/5.3/socket
total 56
-rw-r--r-- 1 root root 10640 Dec 11 21:31 ftp.lua
-rw-r--r-- 1 root root 3698 Dec 11 21:31 headers.lua
-rw-r--r-- 1 root root 14588 Dec 11 21:31 http.lua
-rw-r--r-- 1 root root 8074 Dec 11 21:31 smtp.lua
-rw-r--r-- 1 root root 3766 Dec 11 21:31 tp.lua
-rw-r--r-- 1 root root 11675 Dec 11 21:31 url.lua
It is saying
no file './socket.so' from [C] global 'require', /home/ubuntu/haproxy-mapping.lua:12 C function line 4.
is that the core of the issue? There is no socket.so on the machine
Update: forgot to mention that I can use LuaSocket from Lua directly, just not when it's embedded in HAProxy.
Update 2: I suspect permissions. I ran strace on it and found
open("/usr/local/share/lua/5.3/socket/http.lua", O_RDONLY) = -1 ENOENT (No such file or directory)
and I know that haproxy is running as the user haproxy
me :/usr/local/share/lua/5.3/socket$ ps -o user= -p 3273
haproxy
and yet if I switch user to haproxy I can read the file
me :/usr/local/share/lua/5.3/socket$ su - haproxy
Password:
No directory, logging in with HOME=/
$ more /usr/local/share/lua/5.3/socket/http.lua
...listing...
and I also changed owner of the http.lua file to haproxy and it still can't open the file.
I can only assume this is something to do with the context that the Lua function runs with-in when it is called, because changing the code to
local http = require("socket.http")
core.register_fetches("myfunc", function(txn)
...
worked.
UPDATE: according to this https://www.arpalert.org/src/haproxy-lua-api/1.7/index.html during initialization you can DNS lookups but in runtime mode you cannot. It doesn't say anything about files but it seems reasonable to believe you can't do files either.
I have a jenkins running a job, after which I want it to "archive artifact", which is basically just get some files.
The Job clones a github and when ran, it generates some log files which I need.
The patter is:
logfiles/*
I added a command to list the directory to make sure the files are there, and indeed they are.
+ ls -la logfiles
total 24
drwxr-xr-x 2 root root 4096 Apr 22 23:23 .
drwxr-xr-x 8 root root 4096 Apr 22 23:23 ..
-rw-r--r-- 1 root root 0 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41.log
-rw-r--r-- 1 root root 1248 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41_shortmsg.csv
-rw-r--r-- 1 root root 2521 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41_stats.log
-rw-r--r-- 1 root root 8035 Apr 22 23:23 1461367410777_testuuid_61746144-3A3A-5555-4944-3D5343414C41_trace_msg.log
Archiving artifacts
ERROR: No artifacts found that match the file pattern "logfiles/*". Configuration error?
ERROR: ‘logfiles/*’ doesn’t match anything, but ‘*’ does. Perhaps that’s what you mean?
Build step 'Archive the artifacts' changed build result to FAILURE
I don't really understand why they are not found.
Hope someone can help!
Thanks!
I finally found my problem. I had configured the job to do the git clone. But for some reason I also added the cloning on the build steps... once i removed that jenkins started getting the files properly.
I would still like to understand why this would happen...
Thanks to all
The issue is that I am not able to see thumbnails of the Page layouts. I am working on Liferay Portal EE 6.1.20.
When I go to Manage -> Page Layout, I cannot see the thumbnails.
Few things
I am not using OOB Liferay, it is a custom solution where Liferay is bundled as a custom portal solution
This thing works fine in Liferay OOB, so there must be some configuration issue
I tried to debug with Firebug and it is able to fetch the image from the URL specified.
The context path is changed from / to /portal
The generated image URL is like this /portal/layouttpl/custom/1_2_columns_ii.png. This is also not accessible from the browser itself.
The other URLS like /portal/html or /portal/wap/ working fine. Only from /portal/layouttpl does not allow to access static resources.
Any Idea?
It might be worth checking the file permissions of the images. In my Liferay development enviroment, I have all of my images set to 777:
user#ubuntu:/usr/liferay/tomcat/webapps/ROOT/layouttpl/custom$ ll *.png
-rwxrwxrwx 1 root root 1801 Apr 2 2012 1_2_1_columns.png*
-rwxrwxrwx 1 root root 1798 Apr 2 2012 1_2_columns_ii.png*
-rwxrwxrwx 1 root root 1793 Apr 2 2012 1_2_columns_i.png*
-rwxrwxrwx 1 root root 1425 Apr 2 2012 1_column.png*
-rwxrwxrwx 1 root root 1923 Apr 2 2012 2_2_columns.png*
-rwxrwxrwx 1 root root 1718 Apr 2 2012 2_columns_iii.png*
-rwxrwxrwx 1 root root 1735 Apr 2 2012 2_columns_ii.png*
-rwxrwxrwx 1 root root 1618 Apr 2 2012 2_columns_i.png*
-rwxrwxrwx 1 root root 1852 Apr 2 2012 3_columns.png*
-rwxrwxrwx 1 root root 1740 Apr 2 2012 freeform.png*