MCPcopy
hub / github.com/Dokploy/dokploy / handleScript

Function handleScript

packages/server/src/services/schedule.ts:150–172  ·  view source on GitHub ↗
(schedule: Schedule)

Source from the content-addressed store, hash-verified

148};
149
150const handleScript = async (schedule: Schedule) => {
151 const { SCHEDULES_PATH } = paths(!!schedule?.serverId);
152 const fullPath = path.join(SCHEDULES_PATH, schedule?.appName || "");
153
154 // Add PID and Schedule ID echo by default to all scripts
155 const scriptWithPid = `echo "PID: $$ | Schedule ID: ${schedule.scheduleId}"
156${schedule?.script || ""}`;
157
158 const encodedContent = encodeBase64(scriptWithPid);
159 const script = `
160 mkdir -p ${fullPath}
161 rm -f ${fullPath}/script.sh
162 touch ${fullPath}/script.sh
163 chmod +x ${fullPath}/script.sh
164 echo "${encodedContent}" | base64 -d > ${fullPath}/script.sh
165 `;
166
167 if (schedule?.scheduleType === "dokploy-server") {
168 await execAsync(script);
169 } else if (schedule?.scheduleType === "server") {
170 await execAsyncRemote(schedule?.serverId || "", script);
171 }
172};

Callers 2

createScheduleFunction · 0.85
updateScheduleFunction · 0.85

Calls 4

pathsFunction · 0.90
encodeBase64Function · 0.90
execAsyncFunction · 0.90
execAsyncRemoteFunction · 0.90

Tested by

no test coverage detected