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

check has winsvc feature in luvi #268

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions samples/winsvc.app/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ limitations under the License.

--]]

local options = require('luvi').options
if not options.winsvc then
print("not has winsvc feature, skip");
return
end
local table = require('table')
local winsvc = require('winsvc')
local winsvcaux = require('winsvcaux')
Expand Down Expand Up @@ -55,18 +60,18 @@ end


local function SvcHandler(dwControl, dwEventType, lpEventData, lpContext)
-- Handle the requested control code.
-- Handle the requested control code.

if dwControl == winsvc.SERVICE_CONTROL_STOP then
if dwControl == winsvc.SERVICE_CONTROL_STOP then
ReportSvcStatus(winsvc.SERVICE_STOP_PENDING, winsvc.NO_ERROR, 0)

-- Signal the service to stop.

gRunning = false
ReportSvcStatus(gSvcStatus.dwCurrentState, winsvc.NO_ERROR, 0)

return winsvc.NO_ERROR
elseif dwControl == winsvc.SERVICE_CONTROL_INTERROGATE then
elseif dwControl == winsvc.SERVICE_CONTROL_INTERROGATE then
return winsvc.NO_ERROR
else
return winsvc.ERROR_CALL_NOT_IMPLEMENTED
Expand Down Expand Up @@ -96,7 +101,7 @@ end

local function SvcInit(args, context)
-- TO_DO: Declare and set any required variables.
-- Be sure to periodically call ReportSvcStatus() with
-- Be sure to periodically call ReportSvcStatus() with
-- SERVICE_START_PENDING. If initialization fails, call
-- ReportSvcStatus with SERVICE_STOPPED.

Expand All @@ -106,7 +111,7 @@ local function SvcInit(args, context)
ReportSvcStatus(winsvc.SERVICE_RUNNING, winsvc.NO_ERROR, 0)

-- TO_DO: Setup Serive Work To Be done

local timer = uv.new_timer()
uv.timer_start(timer, 0, 2000, function()
if gRunning then
Expand Down