Skip to content

Commit aed9f85

Browse files
Add PID Modal (pterodactyl#3845)
1 parent 1eaf411 commit aed9f85

File tree

8 files changed

+100
-7
lines changed

8 files changed

+100
-7
lines changed

database/Seeders/eggs/minecraft/egg-bungeecord.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"description": "For a long time, Minecraft server owners have had a dream that encompasses a free, easy, and reliable way to connect multiple Minecraft servers together. BungeeCord is the answer to said dream. Whether you are a small server wishing to string multiple game-modes together, or the owner of the ShotBow Network, BungeeCord is the ideal solution for you. With the help of BungeeCord, you will be able to unlock your community's full potential.",
1111
"features": [
1212
"eula",
13-
"java_version"
13+
"java_version",
14+
"pid_limit"
1415
],
1516
"images": [
1617
"ghcr.io\/pterodactyl\/yolks:java_8",

database/Seeders/eggs/minecraft/egg-forge-minecraft.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"description": "Minecraft Forge Server. Minecraft Forge is a modding API (Application Programming Interface), which makes it easier to create mods, and also make sure mods are compatible with each other.",
1111
"features": [
1212
"eula",
13-
"java_version"
13+
"java_version",
14+
"pid_limit"
1415
],
1516
"images": [
1617
"ghcr.io\/pterodactyl\/yolks:java_17",

database/Seeders/eggs/minecraft/egg-paper.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"description": "High performance Spigot fork that aims to fix gameplay and mechanics inconsistencies.",
1111
"features": [
1212
"eula",
13-
"java_version"
13+
"java_version",
14+
"pid_limit"
1415
],
1516
"images": [
1617
"ghcr.io\/pterodactyl\/yolks:java_8",

database/Seeders/eggs/minecraft/egg-sponge--sponge-vanilla.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"description": "SpongeVanilla is the SpongeAPI implementation for Vanilla Minecraft.",
1111
"features": [
1212
"eula",
13-
"java_version"
13+
"java_version",
14+
"pid_limit"
1415
],
1516
"images": [
1617
"ghcr.io\/pterodactyl\/yolks:java_8",

database/Seeders/eggs/minecraft/egg-vanilla-minecraft.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"description": "Minecraft is a game about placing blocks and going on adventures. Explore randomly generated worlds and build amazing things from the simplest of homes to the grandest of castles. Play in Creative Mode with unlimited resources or mine deep in Survival Mode, crafting weapons and armor to fend off dangerous mobs. Do all this alone or with friends.",
1111
"features": [
1212
"eula",
13-
"java_version"
13+
"java_version",
14+
"pid_limit"
1415
],
1516
"images": [
1617
"ghcr.io\/pterodactyl\/yolks:java_8",

resources/scripts/components/server/ServerConsole.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ServerContentBlock from '@/components/elements/ServerContentBlock';
77
import ServerDetailsBlock from '@/components/server/ServerDetailsBlock';
88
import isEqual from 'react-fast-compare';
99
import PowerControls from '@/components/server/PowerControls';
10-
import { EulaModalFeature, JavaVersionModalFeature, GSLTokenModalFeature } from '@feature/index';
10+
import { EulaModalFeature, JavaVersionModalFeature, GSLTokenModalFeature, PIDLimitModalFeature } from '@feature/index';
1111
import ErrorBoundary from '@/components/elements/ErrorBoundary';
1212
import Spinner from '@/components/elements/Spinner';
1313

@@ -61,6 +61,7 @@ const ServerConsole = () => {
6161
{eggFeatures.includes('eula') && <EulaModalFeature/>}
6262
{eggFeatures.includes('java_version') && <JavaVersionModalFeature/>}
6363
{eggFeatures.includes('gsl_token') && <GSLTokenModalFeature/>}
64+
{eggFeatures.includes('pid_limit') && <PIDLimitModalFeature/>}
6465
</React.Suspense>
6566
</div>
6667
</ServerContentBlock>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, { useEffect, useState } from 'react';
2+
import { ServerContext } from '@/state/server';
3+
import Modal from '@/components/elements/Modal';
4+
import tw from 'twin.macro';
5+
import Button from '@/components/elements/Button';
6+
import FlashMessageRender from '@/components/FlashMessageRender';
7+
import useFlash from '@/plugins/useFlash';
8+
import { SocketEvent } from '@/components/server/events';
9+
import { useStoreState } from 'easy-peasy';
10+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
11+
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
12+
13+
const PIDLimitModalFeature = () => {
14+
const [ visible, setVisible ] = useState(false);
15+
const [ loading ] = useState(false);
16+
17+
const status = ServerContext.useStoreState(state => state.status.value);
18+
const { clearFlashes } = useFlash();
19+
const { connected, instance } = ServerContext.useStoreState(state => state.socket);
20+
const isAdmin = useStoreState(state => state.user.data!.rootAdmin);
21+
22+
useEffect(() => {
23+
if (!connected || !instance || status === 'running') return;
24+
25+
const errors = [
26+
'pthread_create failed',
27+
'Exception in thread "Craft Async Scheduler Management Thread"',
28+
'unable to create new native thread',
29+
'unable to create native thread',
30+
];
31+
32+
const listener = (line: string) => {
33+
if (errors.some(p => line.toLowerCase().includes(p))) {
34+
setVisible(true);
35+
}
36+
};
37+
38+
instance.addListener(SocketEvent.CONSOLE_OUTPUT, listener);
39+
40+
return () => {
41+
instance.removeListener(SocketEvent.CONSOLE_OUTPUT, listener);
42+
};
43+
}, [ connected, instance, status ]);
44+
45+
useEffect(() => {
46+
clearFlashes('feature:pidLimit');
47+
}, []);
48+
49+
return (
50+
<Modal visible={visible} onDismissed={() => setVisible(false)} closeOnBackground={false} showSpinnerOverlay={loading}>
51+
<FlashMessageRender key={'feature:pidLimit'} css={tw`mb-4`} />
52+
{isAdmin ?
53+
<>
54+
<div css={tw`mt-4 sm:flex items-center`}>
55+
<FontAwesomeIcon css={tw`pr-4`} icon={faExclamationTriangle} color={'orange'} size={'4x'}/>
56+
<h2 css={tw`text-2xl mb-4 text-neutral-100 `}>Memory or process limit reached...</h2>
57+
</div>
58+
<p css={tw`mt-4`}>This server has reached the maximum process or memory limit.</p>
59+
<p css={tw`mt-4`}>Increasing <code css={tw`font-mono bg-neutral-900`}>container_pid_limit</code> in the wings configuration, <code css={tw`font-mono bg-neutral-900`}>config.yml</code>, might help resolve this issue.</p>
60+
<p css={tw`mt-4`}><b>Note: Wings must be restarted for the configuration file changes to take effect</b></p>
61+
<div css={tw`mt-8 sm:flex items-center justify-end`}>
62+
<Button onClick={() => setVisible(false)} css={tw`w-full sm:w-auto border-transparent`}>
63+
Close
64+
</Button>
65+
</div>
66+
</>
67+
:
68+
<>
69+
<div css={tw`mt-4 sm:flex items-center`}>
70+
<FontAwesomeIcon css={tw`pr-4`} icon={faExclamationTriangle} color={'orange'} size={'4x'}/>
71+
<h2 css={tw`text-2xl mb-4 text-neutral-100`}>Possible resource limit reached...</h2>
72+
</div>
73+
<p css={tw`mt-4`}>This server is attempting to use more resources than allocated. Please contact the administrator and give them the error below.</p>
74+
<p css={tw`mt-4`}><code css={tw`font-mono bg-neutral-900`}>pthread_create failed, Possibly out of memory or process/resource limits reached</code></p>
75+
<div css={tw`mt-8 sm:flex items-center justify-end`}>
76+
<Button onClick={() => setVisible(false)} css={tw`w-full sm:w-auto border-transparent`}>
77+
Close
78+
</Button>
79+
</div>
80+
</>
81+
}
82+
</Modal>
83+
);
84+
};
85+
86+
export default PIDLimitModalFeature;

resources/scripts/components/server/features/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ import { lazy } from 'react';
99
const EulaModalFeature = lazy(() => import(/* webpackChunkName: "feature.eula" */'@feature/eula/EulaModalFeature'));
1010
const JavaVersionModalFeature = lazy(() => import(/* webpackChunkName: "feature.java_version" */'@feature/JavaVersionModalFeature'));
1111
const GSLTokenModalFeature = lazy(() => import(/* webpackChunkName: "feature.gsl_token" */'@feature/GSLTokenModalFeature'));
12+
const PIDLimitModalFeature = lazy(() => import(/* webpackChunkName: "feature.pid_limit" */'@feature/PIDLimitModalFeature'));
1213

13-
export { EulaModalFeature, JavaVersionModalFeature, GSLTokenModalFeature };
14+
export { EulaModalFeature, JavaVersionModalFeature, GSLTokenModalFeature, PIDLimitModalFeature };

0 commit comments

Comments
 (0)