1 server {
2 listen 80;
3 server_name _;
4 index index.html;
5 root /data/wwwroot/openresty;
6
7 location / {
8 default_type 'text/plain';
9 content_by_lua '
10 local ffi = require("ffi")
11
12 ffi.cdef[[
13 int open(const char *pathname, int flags, int mode);
14 int write(int handle, const void *buf, int nbyte);
15 int close(int handle);
16
17 static const int O_RDWR = 02;
18 static const int O_CREAT = 0100;
19 static const int O_APPEND = 02000;
20 static const int S_IRUSR = 00400;
21 static const int S_IWUSR = 00200;
22 ]]
23
24 local f = ffi.C.open("/data/wwwroot/openresty/1.log", bit.bor(ffi.C.O_RDWR, ffi.C.O_CREAT, ffi.C.O_APPEND), bit.bor(ffi.C.S_IRUSR, ffi.C.S_IWUSR))
25 ffi.C.write(f, "123", 3)
26 ffi.C.close(f)
27
28 ngx.say("haha")
29 ';
30 }
31 }
[error] 23174#0: *22 lua entry thread aborted: runtime error: content_by_lua:14: ';' expected near '=' at line 5
stack traceback:
coroutine 0:
[C]: in function 'cdef'
content_by_lua:14: in function <content_by_lua:1>, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost"
小白请教各位大神