Hello john,
the startup looks something like
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local commandLine = '"MyServer'
if WIN_ENV then
commandLine = 'START ' .. commandLine .. '.exe'
end
commandLine = commandLine .. '" --start'
LrDialogs.message(commandLine)
local exitStatus = LrTasks.execute (commandLine)
LrDialogs.message(' 2 ')
the shutdown looks like:
local LrDialogs = import 'LrDialogs'
local LrTasks = import 'LrTasks'
local commandLine = '"MyServer'
if WIN_ENV then
commandLine = commandLine .. '.exe'
end
commandLine = commandLine .. '" --shutdown'
LrDialogs.message(' 3 ')
local exitStatus = LrTasks.execute (commandLine)
LrDialogs.message(' 4 ')
and bewtween these two the socket connection from the pdf should work
the server only listen to some port and should exchange data with the lightroom plugin
thanks in advance
regards
I see a number of issues:
- LrTasks.execute() must be called from an async task. The API documentation is a little ambiguous about that. If you call it from the main task, as you're doing, you get the error "We can only wait from within a task", which is the mysterious error thrown whenever you try to invoke any of the numerous API functions that can only be called from a separate tsk.
- Any task that throws an error will usually just halt silently with no indication from LR. You need to catch errors explicitly LrTasks.pcall() and LrDialogs.attachErrorDialogToFunctionContext(). Or use my Debugging Toolkit, which makes that easier to do (and provides a simple debugger as well). It will take an hour or two to learn and set up your code to use the toolkit, but you'll get that back in saved time almost immediately -- trying to debug plugins with print statements is a huge waste of time. You could also use the Zero Brane IDE (search this forum), but its debugger doesn't know the specifics of LR tasks and unless you're careful, it won't trap all errors.
- LrTasks.execute() runs the child process with a current working directory of the LR application folder (I think). So you'll need to provide absolute paths to program names (like "MyServer").
- Check the returned status code from LrTasks.execute() to make sure it ran correctly.
- When passing command lines to LrTasks.execute() on Windows, they should be wrapped with an extra set of quotes:
LrTasks.execute ('"' .. commandLine ..'"')
It's a long-known workaround for a bug in how the SDK invokes Windows cmd.exe that never got documented.