lua

How I can to get custom options in the `init` function of the Tarantool Cartridge role?

ぃ、小莉子 提交于 2021-01-27 05:14:39
问题 A Tarantool Cartridge role file has a function init . I want to get my custom options from the instance.yml file. But the opts variable doesn't have it. How I can do it? 回答1: Cartridge has a built-in module called "argparse". It parses a few sources of configuration and combines them together: instances.yml or files in /etc/tarantool/conf.d command line arguments environment variables starting with TARANTOOL_ Cartridge uses this module to get various pieces of configuration like the port

Unable to find Lua headers with find_package in cmake

有些话、适合烂在心里 提交于 2021-01-27 03:54:55
问题 I'm trying to use CMake to build generate the make file for a project of mine that uses Lua. When I run make I get this error: /path/to/my/project/luaudio/luaudio.c:1:17: fatal error: lua.h: No such file or directory In the CMakeLists.txt file, I have the following lines, which I thought would do it, but apparently they're not enough: find_package(Lua51 REQUIRED) set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${Lua51_INCLUDE_DIRS} PARENT_SCOPE) include_directories(${Luaudio_INCLUDE_DIRS})

Unable to find Lua headers with find_package in cmake

眉间皱痕 提交于 2021-01-27 03:54:13
问题 I'm trying to use CMake to build generate the make file for a project of mine that uses Lua. When I run make I get this error: /path/to/my/project/luaudio/luaudio.c:1:17: fatal error: lua.h: No such file or directory In the CMakeLists.txt file, I have the following lines, which I thought would do it, but apparently they're not enough: find_package(Lua51 REQUIRED) set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${Lua51_INCLUDE_DIRS} PARENT_SCOPE) include_directories(${Luaudio_INCLUDE_DIRS})

每日一面

强颜欢笑 提交于 2021-01-26 08:11:58
麻烦大家帮我 投一票 哈,谢谢 什么是分布式锁 针对共享内存模型的程序(例如JAVA程序),锁就是一个非常常用的机制。 一般简单分为悲观锁和乐观锁。悲观锁就是你获取这块数据的锁之后,别人就无法访问或操作这块数据,直到你释放这个锁。乐观锁一般就是CAS更新。 在单进程内内存的锁,只控制进程内数据的,就是非分布式锁。相反的,跨进程,需要锁住多个进程访问数据的锁就是分布式锁。 悲观锁一般由Redis的 SETNXEX 实现,Key 为资源名,EX 设置一个合理的超时时间, Value 设置为一个客户端生成的在超时时间内不会重复的随机字符串。 lua脚本特性说明 由于redis是单线程的,执行lua脚本的时候,不会同时执行其他客户端命令,这一定程度上保证了并发安全 单进程Redis分布式悲观锁实现思路 悲观锁一般由Redis的 SETNX 实现,通过 SETNX 获取一个锁,释放锁就把这个Key删除即可。 例如,获取一个名为TestLock的锁,通过 SETNX TestLock TestLockValue ,TestLockValue随意设置一个值。 SETNX 是SET IF NOT EXISTS,如果不存在就会设置成功。 设置成功会返回1,没设置成功会返回0。返回1代表获取锁成功,0代表没获取成功。 释放锁调用 DEL 命令,通过 DEL TestLock 释放锁

Interprocess communication in Lua with Example?

霸气de小男生 提交于 2021-01-21 10:26:32
问题 I have been struggling a lot to get this to work. Can someone provide an example with any LUA api of 2 scripts that pass a message back and forth. I have tried Oil, lua-ipc and zeromq. But I face several missing libraries issues. The ultimate goal is to pass a vector of numbers from one Lua process to another Lua process (with a different version of Lua) without going through disk. Here is a similar example in python of IPC in a single file. Something similar in lua would be extremely helpful

Lua 'require' but files are only in memory

[亡魂溺海] 提交于 2021-01-21 04:09:30
问题 Setting: I'm using Lua from a C/C++ environment. I have several lua files on disk. Those are read into memory and some more memory-only lua files become available during runtime. Think e.g. of an editor, with additional unsaved lua files. So, I have a list<identifier, lua_file_content> in memory. Some of these files have require statements in them. When I try to load all these files to a lua instance (currently via lua_dostring ) I get attempt to call global require (a nil value) . Is there a

Lua 'require' but files are only in memory

纵饮孤独 提交于 2021-01-21 04:08:58
问题 Setting: I'm using Lua from a C/C++ environment. I have several lua files on disk. Those are read into memory and some more memory-only lua files become available during runtime. Think e.g. of an editor, with additional unsaved lua files. So, I have a list<identifier, lua_file_content> in memory. Some of these files have require statements in them. When I try to load all these files to a lua instance (currently via lua_dostring ) I get attempt to call global require (a nil value) . Is there a

Lua 'require' but files are only in memory

隐身守侯 提交于 2021-01-21 04:07:42
问题 Setting: I'm using Lua from a C/C++ environment. I have several lua files on disk. Those are read into memory and some more memory-only lua files become available during runtime. Think e.g. of an editor, with additional unsaved lua files. So, I have a list<identifier, lua_file_content> in memory. Some of these files have require statements in them. When I try to load all these files to a lua instance (currently via lua_dostring ) I get attempt to call global require (a nil value) . Is there a

Lua 'require' but files are only in memory

若如初见. 提交于 2021-01-21 04:07:13
问题 Setting: I'm using Lua from a C/C++ environment. I have several lua files on disk. Those are read into memory and some more memory-only lua files become available during runtime. Think e.g. of an editor, with additional unsaved lua files. So, I have a list<identifier, lua_file_content> in memory. Some of these files have require statements in them. When I try to load all these files to a lua instance (currently via lua_dostring ) I get attempt to call global require (a nil value) . Is there a

proxy_pass does not resolve DNS using /etc/hosts

本秂侑毒 提交于 2021-01-20 18:00:12
问题 In nginx the proxy_pass directive is not resolving DNS using the /etc/hosts file. Any way to enable this possibility (maybe by leveraging Lua as a last resort)? 回答1: In short, you need to install dnsmasq locally and use 127.0.0.1 as a resolver. See this related question and answer: When using proxy_pass, can /etc/hosts be used to resolve domain names instead of "resolver"? 回答2: If you have a server with systemd you can use the nameserver shipped with it, systemd-resolved, to resolve your