Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
a631ee1e
Commit
a631ee1e
authored
11 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Service code refactored
parent
493666da
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/main.c
+8
-12
8 additions, 12 deletions
build/main.c
with
8 additions
and
12 deletions
build/main.c
+
8
−
12
View file @
a631ee1e
...
@@ -414,32 +414,29 @@ static HICON hIcon;
...
@@ -414,32 +414,29 @@ static HICON hIcon;
static
SERVICE_STATUS
ss
;
static
SERVICE_STATUS
ss
;
static
SERVICE_STATUS_HANDLE
hStatus
;
static
SERVICE_STATUS_HANDLE
hStatus
;
static
const
char
*
service_magic_argument
=
"--"
;
static
const
char
*
service_magic_argument
=
"--"
;
static
const
char
*
service_name
=
"Mongoose"
;
static
NOTIFYICONDATA
TrayIcon
;
static
NOTIFYICONDATA
TrayIcon
;
static
void
WINAPI
ControlHandler
(
DWORD
code
)
{
static
void
WINAPI
ControlHandler
(
DWORD
code
)
{
ss
.
dwControlsAccepted
=
SERVICE_ACCEPT_STOP
|
SERVICE_ACCEPT_SHUTDOWN
;
ss
.
dwServiceType
=
SERVICE_WIN32
;
ss
.
dwWin32ExitCode
=
NO_ERROR
;
ss
.
dwCurrentState
=
SERVICE_RUNNING
;
if
(
code
==
SERVICE_CONTROL_STOP
||
code
==
SERVICE_CONTROL_SHUTDOWN
)
{
if
(
code
==
SERVICE_CONTROL_STOP
||
code
==
SERVICE_CONTROL_SHUTDOWN
)
{
ss
.
dwWin32ExitCode
=
0
;
ss
.
dwCurrentState
=
SERVICE_STOPPED
;
ss
.
dwCurrentState
=
SERVICE_STOPPED
;
}
}
SetServiceStatus
(
hStatus
,
&
ss
);
SetServiceStatus
(
hStatus
,
&
ss
);
}
}
static
void
WINAPI
ServiceMain
(
void
)
{
static
void
WINAPI
ServiceMain
(
void
)
{
ss
.
dwServiceType
=
SERVICE_WIN32
;
hStatus
=
RegisterServiceCtrlHandler
(
service_name
,
ControlHandler
);
ss
.
dwCurrentState
=
SERVICE_RUNNING
;
ControlHandler
(
SERVICE_CONTROL_INTERROGATE
);
ss
.
dwControlsAccepted
=
SERVICE_ACCEPT_STOP
|
SERVICE_ACCEPT_SHUTDOWN
;
hStatus
=
RegisterServiceCtrlHandler
(
server_name
,
ControlHandler
);
SetServiceStatus
(
hStatus
,
&
ss
);
while
(
ss
.
dwCurrentState
==
SERVICE_RUNNING
)
{
while
(
ss
.
dwCurrentState
==
SERVICE_RUNNING
)
{
Sleep
(
1000
);
Sleep
(
1000
);
}
}
mg_stop
(
ctx
);
mg_stop
(
ctx
);
ss
.
dwCurrentState
=
SERVICE_STOPPED
;
ss
.
dwWin32ExitCode
=
(
DWORD
)
-
1
;
SetServiceStatus
(
hStatus
,
&
ss
);
}
}
...
@@ -719,7 +716,6 @@ static void show_settings_dialog() {
...
@@ -719,7 +716,6 @@ static void show_settings_dialog() {
}
}
static
int
manage_service
(
int
action
)
{
static
int
manage_service
(
int
action
)
{
static
const
char
*
service_name
=
"Mongoose"
;
SC_HANDLE
hSCM
=
NULL
,
hService
=
NULL
;
SC_HANDLE
hSCM
=
NULL
,
hService
=
NULL
;
SERVICE_DESCRIPTION
descr
=
{
server_name
};
SERVICE_DESCRIPTION
descr
=
{
server_name
};
char
path
[
PATH_MAX
+
20
];
// Path to executable plus magic argument
char
path
[
PATH_MAX
+
20
];
// Path to executable plus magic argument
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment