add pause/resume service controls
This commit is contained in:
parent
1be17d8e6d
commit
6bfbfad766
|
@ -15,6 +15,8 @@ public class Win32Service extends SigarCommandBase {
|
|||
"state",
|
||||
"start",
|
||||
"stop",
|
||||
"pause",
|
||||
"resume",
|
||||
"restart",
|
||||
});
|
||||
|
||||
|
@ -67,6 +69,12 @@ public class Win32Service extends SigarCommandBase {
|
|||
else if (cmd.equals("stop")) {
|
||||
service.stop();
|
||||
}
|
||||
else if (cmd.equals("pause")) {
|
||||
service.pause();
|
||||
}
|
||||
else if (cmd.equals("resume")) {
|
||||
service.resume();
|
||||
}
|
||||
else if (cmd.equals("delete")) {
|
||||
service.delete();
|
||||
}
|
||||
|
|
|
@ -262,6 +262,30 @@ public class Service extends Win32 {
|
|||
}
|
||||
}
|
||||
|
||||
public void pause() throws Win32Exception
|
||||
{
|
||||
control(CONTROL_PAUSE);
|
||||
}
|
||||
|
||||
public void pause(long timeout) throws Win32Exception
|
||||
{
|
||||
long status;
|
||||
|
||||
pause();
|
||||
|
||||
Waiter waiter =
|
||||
new Waiter(this, timeout, SERVICE_PAUSED, SERVICE_PAUSE_PENDING);
|
||||
|
||||
if (!waiter.sleep()) {
|
||||
throw new Win32Exception("Failed to pause service");
|
||||
}
|
||||
}
|
||||
|
||||
public void resume() throws Win32Exception
|
||||
{
|
||||
control(CONTROL_RESUME);
|
||||
}
|
||||
|
||||
public ServiceConfig getConfig() throws Win32Exception {
|
||||
ServiceConfig config = new ServiceConfig();
|
||||
QueryServiceConfig(this.service, config);
|
||||
|
|
Loading…
Reference in New Issue