Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the new cabsagent work on windows
- Loading branch information
1 parent
85865ab
commit 96e2b36
Showing
14 changed files
with
166 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ venv | |
*.rpm | ||
*.deb | ||
dist | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SHELL=/bin/bash | ||
SHELLFLAGS="-O extglob -c" | ||
VERSION=$(shell cat ../version.txt) | ||
NAME=cabsagent-windows-$(VERSION) | ||
DIR=build/$(NAME) | ||
|
||
default: installer archive | ||
|
||
archive: | ||
mkdir -p $(DIR) | ||
cd app && cp agent_server.pem \ | ||
broker_cert.pem \ | ||
cabsagent.conf \ | ||
cabsagentsvc.exe \ | ||
install.exe \ | ||
../$(DIR) | ||
cd build && zip -r $(NAME).zip $(NAME)/ | ||
|
||
installer: | ||
makensis app/install.nsi | ||
|
||
clean: | ||
rm -rf build/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import win32serviceutil | ||
import win32event | ||
import win32service | ||
import win32api | ||
import servicemanager | ||
import time | ||
import cabsagent | ||
import sys | ||
import os | ||
#from sched import scheduler | ||
|
||
class AgentService(win32serviceutil.ServiceFramework): | ||
#_svc_name_ = "aservice" | ||
#_svc_display_name_ = "a service - it does nothing" | ||
#_svc_description_ = "foo bar" | ||
_svc_name_ = "CABS_Agent" | ||
_svc_display_name_ = "CABS Agent" | ||
_svc_description_ = "The Agent reporting to the CABS Broker" | ||
|
||
def __init__(self, args): | ||
win32serviceutil.ServiceFramework.__init__(self, args) | ||
self.stop_event = win32event.CreateEvent(None, 0, 0, None) | ||
|
||
def SvcStop(self): | ||
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) | ||
win32event.SetEvent(self.stop_event) | ||
cabsagent.stop() | ||
|
||
def SvcDoRun(self): | ||
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, | ||
servicemanager.PYS_SERVICE_STARTED, | ||
(self._svc_name_, '')) | ||
cabsagent.start() | ||
|
||
# These methods can be used instead for testing. | ||
|
||
# def __init__(self, args): | ||
# win32serviceutil.ServiceFramework.__init__(self, args) | ||
# #logfile = os.path.join(os.getenv('APPDATA'), 'cabsagent.log') | ||
# #print("log location:", logfile) | ||
# #logging.basicConfig(filename=logfile, format='%(asctime)s %(message)s', | ||
# # level=logging.DEBUG) | ||
# #logging.info("AgentService.__init__()") | ||
# self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) | ||
# #self.stop_requested = False | ||
# | ||
# def SvcStop(self): | ||
# self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) | ||
# win32event.SetEvent(self.hWaitStop) | ||
# | ||
# def SvcDoRun(self): | ||
# self.ReportServiceStatus(win32service.SERVICE_RUNNING) | ||
# import servicemanager | ||
# servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, | ||
# servicemanager.PYS_SERVICE_STARTED, | ||
# (self._svc_name_, '')) | ||
# self.timeout = 3000 | ||
# | ||
# while 1: | ||
# rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout) | ||
# if rc == win32event.WAIT_OBJECT_0: | ||
# servicemanager.LogInfoMsg("aservice - STOPPED") | ||
# break | ||
# else: | ||
# servicemanager.LogInfoMsg("aservice - is alive and well") | ||
# | ||
#def ctrlHandler(ctrlType): | ||
# return True | ||
|
||
if __name__ == "__main__": | ||
#win32api.SetConsoleCtrlHandler(ctrlHandler, True) | ||
#win32serviceutil.HandleCommandLine(aservice) | ||
if len(sys.argv) == 1: | ||
servicemanager.Initialize() | ||
servicemanager.PrepareToHostSingle(AgentService) | ||
servicemanager.StartServiceCtrlDispatcher() | ||
else: | ||
win32serviceutil.HandleCommandLine(AgentService) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.