(schedule: Schedule)
| 148 | }; |
| 149 | |
| 150 | const 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 | }; |
no test coverage detected