Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to push 3rd party modules to plugin package #9

Open
spigell opened this issue Aug 11, 2019 · 1 comment
Open

Function to push 3rd party modules to plugin package #9

spigell opened this issue Aug 11, 2019 · 1 comment

Comments

@spigell
Copy link
Contributor

spigell commented Aug 11, 2019

Greetings. Let's assume we have any golang package for glua-libs in somewhere outside of this repo. For example, ssh - https://github.com/spigell/luscheduler/tree/master/libs/ssh. There is no big deal to add glua-libs and custom resources to project, but if we will use plugin package with 3rd party modules inside then it seems to not loading.

local plugin = require("plugin")

local plugin_body = [[
    local time = require("time")
    local chef = require("chef")
    local cron = require("ssh")

    local i = 1
    print(i)
    time.sleep(2)
]]

local string_plugin = plugin.do_string(plugin_body)
string_plugin:run()

time.sleep(1)
if file_plugin:is_running() then
  print("RUNNING")
else
  print("NOT RUNNING")
  print(string_plugin:error())
end

NOT RUNNING
<string>:3: module ssh not found:
	no field package.preload['ssh']
	stat ./ssh.lua: no such file or directory
	stat /usr/local/share/lua/5.1/ssh.lua: no such file or directory
	stat /usr/local/share/lua/5.1/ssh/init.lua: no such file or directory, 
stack traceback:
	[G]: in function 'require'
	<string>:3: in main chunk
	[G]: ?

In plugin package creates a new Lua state with only static list of modules - https://github.com/vadv/gopher-lua-libs/blob/master/plugin/api.go#L75
Is there any change add modules to preload table in the state?

Loader returned by require contains only Lua table with methods without metadata and do not fit for PreloadModules function.

@spigell
Copy link
Contributor Author

spigell commented Aug 11, 2019

Make PR. Could you take a look? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant