mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Update schedule management with shell type support and version upgrades
- Updated the `drizzle-zod` package to version 0.7.1 across the project for enhanced schema validation. - Introduced a new `shellType` column in the `schedule` schema to specify the shell used for executing commands, defaulting to 'bash'. - Enhanced the `HandleSchedules` component to include the new `shellType` field, allowing users to select the shell type when creating or updating schedules. - Updated the `runCommand` utility to utilize the selected shell type when executing commands, improving flexibility in command execution. - Refactored the API to accommodate the new `shellType` in schedule creation and updates, ensuring proper handling of the new field.
This commit is contained in:
@@ -19,7 +19,8 @@ export const scheduleJob = (schedule: Schedule) => {
|
||||
};
|
||||
|
||||
export const runCommand = async (scheduleId: string) => {
|
||||
const { application, command } = await findScheduleById(scheduleId);
|
||||
const { application, command, shellType } =
|
||||
await findScheduleById(scheduleId);
|
||||
|
||||
const isServer = !!application.serverId;
|
||||
|
||||
@@ -42,7 +43,8 @@ export const runCommand = async (scheduleId: string) => {
|
||||
application.serverId,
|
||||
`
|
||||
set -e
|
||||
docker exec ${containerId} sh -c "${command}" || {
|
||||
echo "Running command: docker exec ${containerId} ${shellType} -c \"${command}\"" >> ${deployment.logPath};
|
||||
docker exec ${containerId} ${shellType} -c "${command}" || {
|
||||
echo "❌ Command failed" >> ${deployment.logPath};
|
||||
exit 1;
|
||||
}
|
||||
@@ -56,10 +58,12 @@ export const runCommand = async (scheduleId: string) => {
|
||||
const writeStream = createWriteStream(deployment.logPath, { flags: "a" });
|
||||
|
||||
try {
|
||||
writeStream.write(`${command}\n`);
|
||||
writeStream.write(
|
||||
`docker exec ${containerId} ${shellType} -c "${command}"\n`,
|
||||
);
|
||||
await spawnAsync(
|
||||
"docker",
|
||||
["exec", containerId, "sh", "-c", command],
|
||||
["exec", containerId, shellType, "-c", command],
|
||||
(data) => {
|
||||
if (writeStream.writable) {
|
||||
writeStream.write(data);
|
||||
|
||||
Reference in New Issue
Block a user