MCPcopy Index your code
hub / github.com/Dokploy/dokploy / serverSetup

Function serverSetup

packages/server/src/setup/server-setup.ts:47–107  ·  view source on GitHub ↗
(
	serverId: string,
	onData?: (data: any) => void,
)

Source from the content-addressed store, hash-verified

45};
46
47export const serverSetup = async (
48 serverId: string,
49 onData?: (data: any) => void,
50) => {
51 const server = await findServerById(serverId);
52 const { LOGS_PATH } = paths();
53
54 const slugifyName = slugify(`server ${server.name}`);
55
56 const fullPath = path.join(LOGS_PATH, slugifyName);
57
58 await recreateDirectory(fullPath);
59
60 const deployment = await createServerDeployment({
61 serverId: server.serverId,
62 title: "Setup Server",
63 description: "Setup Server",
64 });
65
66 try {
67 const isBuildServer = server.serverType === "build";
68 onData?.(
69 isBuildServer
70 ? "\nInstalling Build Server Dependencies: ✅\n"
71 : "\nInstalling Server Dependencies: ✅\n",
72 );
73 await installRequirements(serverId, onData);
74
75 if (IS_CLOUD) {
76 onData?.("\nConfiguring Monitoring: 🔄\n");
77
78 const baseUrl = await getDokployUrl();
79 const token = generateToken();
80 const urlCallback = `${baseUrl}/api/trpc/notification.receiveNotification`;
81
82 // Update server with monitoring configuration
83 await updateServerById(serverId, {
84 metricsConfig: {
85 server: {
86 ...server.metricsConfig.server,
87 token: token,
88 urlCallback: urlCallback,
89 },
90 containers: server.metricsConfig.containers,
91 },
92 });
93
94 await setupMonitoring(serverId);
95 onData?.("\nMonitoring Configured: ✅\n");
96 }
97
98 await updateDeploymentStatus(deployment.deploymentId, "done");
99
100 onData?.("\nSetup Server: ✅\n");
101 } catch (err) {
102 console.log(err);
103
104 await updateDeploymentStatus(deployment.deploymentId, "error");

Callers 1

server.tsFile · 0.90

Calls 12

findServerByIdFunction · 0.90
pathsFunction · 0.90
recreateDirectoryFunction · 0.90
createServerDeploymentFunction · 0.90
getDokployUrlFunction · 0.90
updateServerByIdFunction · 0.90
setupMonitoringFunction · 0.90
updateDeploymentStatusFunction · 0.90
installRequirementsFunction · 0.85
slugifyFunction · 0.70
generateTokenFunction · 0.70
onDataFunction · 0.50

Tested by

no test coverage detected