Skip to content

Commit d1d9821

Browse files
committed
CHANGES:
- Scheduler supports "stop" now also. - Callback for "stop_server" added.
1 parent 9c228d5 commit d1d9821

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

plugins/mission/listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def display_player_embed(self, server: Server):
238238

239239
@event(name="callback")
240240
async def callback(self, server: Server, data: dict):
241-
if data['subcommand'] in ['startMission', 'restartMission', 'pause', 'shutdown']:
241+
if data['subcommand'] in ['startMission', 'restartMission', 'pause', 'shutdown', 'stop_server']:
242242
data['command'] = data['subcommand']
243243
asyncio.create_task(server.send_to_dcs(data))
244244

plugins/scheduler/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ Here you can provide a mission_id to be started on server startup.
8484
8585
### Section "action"
8686
87-
| Parameter | Description |
88-
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
89-
| method | One of **restart**, **rotate**, **load** or **shutdown**.<br/>- "restart" will restart the current mission,<br/>- "shutdown" will only shutdown the server<br/>- "rotate" will launch the next mission in the mission list.<br/>- "load" will load a specific mission. |
90-
| shutdown | If true, the server will be shut down prior to restarting or rotating (default: false). |
91-
| mission_time | Time in minutes (according to the mission time passed) when the mission has to be restarted. |
92-
| max_mission_time | Time in minutes (according to the mission time passed) when the mission has to be restarted, even if people are in. |
93-
| real_time | Time in minutes since the start of your server (not necessarily your mission, if that is paused for instance), when a restart should happen. Only works with restart_with_shutdown. |
94-
| idle_time | Time in minutes, the server was not in use (no people in the server) |
95-
| local_times | List of times in the format HH24:MM, when the mission should be restated or rotated (see method). |
96-
| utc_times | Like local_times but UTC. |
97-
| mission_id | For load only: the mission_id to load (1 = first from the mission list). Can be an integer or a list of integers for random pick. |
98-
| mission_file | For load only: the mission file name to load (has to be in the mission list). Can be a single mission or list of missions for random pick. |
99-
| populated | If **false**, the mission will be restarted / rotated only, if no player is in (default: true). |
100-
| mission_end | Only apply the method on mission end (usually in combination with restart_with_shutdown). |
101-
| run_extensions | If true, extensions will be applied to the mission prior to the restart / rotation (default: true) . |
87+
| Parameter | Description |
88+
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
89+
| method | One of **restart**, **rotate**, **load**, **stop** or **shutdown**.<br/>- "restart" will restart the current mission,<br/>- "shutdown" will only shutdown the server<br/>- "rotate" will launch the next mission in the mission list.<br/>- "load" will load a specific mission. |
90+
| shutdown | If true, the server will be shut down prior to restarting or rotating (default: false). |
91+
| mission_time | Time in minutes (according to the mission time passed) when the mission has to be restarted. |
92+
| max_mission_time | Time in minutes (according to the mission time passed) when the mission has to be restarted, even if people are in. |
93+
| real_time | Time in minutes since the start of your server (not necessarily your mission, if that is paused for instance), when a restart should happen. Only works with restart_with_shutdown. |
94+
| idle_time | Time in minutes, the server was not in use (no people in the server) |
95+
| local_times | List of times in the format HH24:MM, when the mission should be restated or rotated (see method). |
96+
| utc_times | Like local_times but UTC. |
97+
| mission_id | For load only: the mission_id to load (1 = first from the mission list). Can be an integer or a list of integers for random pick. |
98+
| mission_file | For load only: the mission file name to load (has to be in the mission list). Can be a single mission or list of missions for random pick. |
99+
| populated | If **false**, the mission will be restarted / rotated only, if no player is in (default: true). |
100+
| mission_end | Only apply the method on mission end (usually in combination with restart_with_shutdown). |
101+
| run_extensions | If true, extensions will be applied to the mission prior to the restart / rotation (default: true) . |
102102
103103
### on-commands
104104

plugins/scheduler/commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ async def restart_mission(self, server: Server, config: dict, rconf: dict, max_w
324324
except (TimeoutError, asyncio.TimeoutError):
325325
await self.bot.audit(f"{self.plugin_name.title()}: Timeout while starting server",
326326
server=server)
327+
elif method == 'stop':
328+
self.log.debug(f"Scheduler: Stopping DCS Server {server.name} ...")
329+
await server.stop()
330+
await self.bot.audit(f"{self.plugin_name.title()} stopped DCS Server {server.name}",
331+
server=server)
327332
elif method == 'load':
328333
try:
329334
mission_id = rconf.get('mission_id')

plugins/scheduler/listener.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ async def process(self, server: Server, what: dict) -> None:
115115
await server.loadNextMission(modify_mission=run_extensions, use_orig=use_orig)
116116
asyncio.create_task(self.bot.audit(f"{self.plugin_name.title()} rotated to mission "
117117
f"{server.current_mission.display_name}", server=server))
118+
elif what['command'] == 'stop':
119+
await server.stop()
120+
asyncio.create_task(self.bot.audit(f"{self.plugin_name.title()} stopped server", server=server))
118121
elif what['command'] == 'load':
119122
run_extensions = what.get('run_extensions', True)
120123
use_orig = what.get('use_orig', True)

plugins/scheduler/schemas/scheduler_schema.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ schema;action_map:
2020
max_mission_time: { type: int, range: { min: 1 }, nullable: false }
2121
real_time: { type: int, range: { min: 1 }, nullable: false }
2222
idle_time: { type: int, range: { min: 1 }, nullable: false }
23-
method: { type: str, enum: [ 'restart', 'rotate', 'shutdown', 'load' ], nullable: false }
23+
method: { type: str, enum: ['restart', 'rotate', 'shutdown', 'stop', 'load'], nullable: false }
2424
mission_id: { type: any, nullable: false, func: int_or_list }
2525
mission_file: { type: any, nullable: false, func: str_or_list }
2626
populated: { type: bool, nullable: false }

0 commit comments

Comments
 (0)