Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6af82bb2
authored
Feb 11, 2024
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winservice fix
parent
c88ceaa3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
5 deletions
+25
-5
agent-winservice.py
+14
-3
watchdog-winservice.py
+11
-2
win_exe/agent-winservice.exe
+0
-0
win_exe/watchdog-winservice.exe
+0
-0
No files found.
agent-winservice.py
View file @
6af82bb2
...
...
@@ -27,11 +27,12 @@ logger.info("%s loaded", __file__)
class
AppServerSvc
(
win32serviceutil
.
ServiceFramework
):
_svc_name_
=
"circle-agent"
_svc_display_name_
=
"CIRCLE Agent"
_svc_desciption_
=
"CIRCLE cloud contextualization agent"
def
__init__
(
self
,
args
):
win32serviceutil
.
ServiceFramework
.
__init__
(
self
,
args
)
self
.
hWaitStop
=
win32event
.
CreateEvent
(
None
,
0
,
0
,
None
)
socket
.
setdefaulttimeout
(
6
0
)
socket
.
setdefaulttimeout
(
12
0
)
def
SvcStop
(
self
):
self
.
ReportServiceStatus
(
win32service
.
SERVICE_STOP_PENDING
)
...
...
@@ -40,15 +41,25 @@ class AppServerSvc (win32serviceutil.ServiceFramework):
logger
.
info
(
"
%
s stopped"
,
__file__
)
def
SvcDoRun
(
self
):
logger
.
info
(
"
%
s starting"
,
__file__
)
cnt
=
3
while
cnt
>
0
:
try
:
servicemanager
.
LogMsg
(
servicemanager
.
EVENTLOG_INFORMATION_TYPE
,
servicemanager
.
PYS_SERVICE_STARTED
,
(
self
.
_svc_name_
,
''
))
logger
.
info
(
"
%
s starting"
,
__file__
)
break
except
Exception
as
e
:
logger
.
exception
(
"Servicemanager busy?"
,
e
)
cnt
-=
1
if
cnt
:
logger
.
info
(
"Starting agent_main"
)
agent_main
()
def
main
():
if
len
(
sys
.
argv
)
==
1
:
# never happen set 1 for debugging!!!!
logger
.
info
(
"Started:
%
s"
,
sys
.
argv
)
if
len
(
sys
.
argv
)
==
1
:
# service must be starting...
# for the sake of debugging etc, we use win32traceutil to see
# any unhandled exceptions and print statements.
...
...
watchdog-winservice.py
View file @
6af82bb2
...
...
@@ -31,13 +31,21 @@ def watch():
def
start_service
():
win32serviceutil
.
StartService
(
service_name
)
timo_base
=
10
timo
=
timo_base
while
True
:
if
not
check_service
(
service_name
):
logger
.
info
(
"Service
%
s is not running."
,
service_name
)
try
:
start_service
()
timo
=
timo_base
logger
.
info
(
"Service
%
s started."
,
service_name
)
except
Exception
as
e
:
timo
*=
2
logger
.
exception
(
"Cant start service
%
s new timo:
%
s"
%
(
service_name
,
timo
))
if
stopped
:
return
sleep
(
10
)
sleep
(
timo
)
class
AppServerSvc
(
win32serviceutil
.
ServiceFramework
):
...
...
@@ -65,7 +73,8 @@ class AppServerSvc (win32serviceutil.ServiceFramework):
def
main
():
if
len
(
sys
.
argv
)
==
1
:
# never happen set 1 for debugging!!!!
logger
.
info
(
"Started:
%
s"
,
sys
.
argv
)
if
len
(
sys
.
argv
)
==
1
:
# service must be starting...
# for the sake of debugging etc, we use win32traceutil to see
# any unhandled exceptions and print statements.
...
...
win_exe/agent-winservice.exe
View file @
6af82bb2
No preview for this file type
win_exe/watchdog-winservice.exe
View file @
6af82bb2
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment