inlife / nexrender

📹 Data-driven render automation for After Effects

Home Page:https://www.nexrender.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error while updating job state to started. job abandoned

RezaRamezanisani opened this issue · comments

error while updating job state to started. job abandoned.

version 1.43.1
i use from worker programic in cmd : 'node nexrenderWorker.js'

  • Are you using pre-built binaries or globally installed npm packages? yes
  • Which kind (and version) of operating system you are running it in? windows
    20230815_094507
    please help me thanks you.

Hey
Could you show the code you are using?

hey
this is my code worker:

const { start } = require('@nexrender/worker');

const main = async () => {
    const serverHost = '...'
    const serverSecret = '...'
    await start(serverHost, serverSecret, {
        workpath: 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\nexrender2',
        binary: '/Users/mynames/Apllications/aerender',
        skipCleanup: true,
        tagSelector: false,
        addLicense: false,
        debug: true,
        stopOnError:false
    });
}
main().catch(console.error);

and this code js for preDwonload action:

const axios = require('axios');
const fs = require('fs');
const AdmZip = require('adm-zip');
      const { updateStatus } = require('./updateStatus');

module.exports = (job, settings, action, type) => {
  job.onChange = (job, state) => {
    switch (state) {
      case 'render:dorender':
        updateStatus('2', job.uid, job.startedAt);
        break;
      case 'render:cleanup':
          if(!job.error){
              updateStatus('3', job.uid, job.finishedAt);
          }else{
              updateStatus('6', job.uid, job.errorAt);
          }
        break;
        case 'error' :
       updateStatus('6', job.uid, job.errorAt);
    }
  };

  job.onRenderProgress = (job, progress) => {
    let host = '...';
    axios
      .patch(`${host}/api/v1/user-project-output/update-progress/${action.id}`, {
        progress: progress,
      })
      .then((response) => {
        if (response.data.status === 'success') {
          console.log(response.data.message);
        } else if (response.data.status === 'error') {
          console.log(response.data.message);
        }
      })
      .catch((error) => {
        console.error(error);
      });
  };

  const url = action.url;
  const extractToPath = action.extractToPath;
  const userOutputPath = action.userOutputPath;
  const fileName = url.split('/').pop();
  const filePath = `${extractToPath}/${fileName}`;

  return new Promise((resolve, reject) => {
    // Check if the directory exists, create it if it doesn't
    if (!fs.existsSync(extractToPath)) {
      console.log(`Directory ${extractToPath} does not exist. Creating...`);
      fs.mkdirSync(extractToPath, { recursive: true });
    }

    if (!fs.existsSync(userOutputPath)) {
      console.log(`Directory ${userOutputPath} does not exist. Creating...`);
      fs.mkdirSync(userOutputPath, { recursive: true });
    }

	console.log(filePath);
    // Check if the file already exists in the directory
    if (fs.existsSync(filePath)) {
      console.log(`File ${fileName} already exists in ${extractToPath}`);
      // Skip the download and extraction steps
      resolve();
    } else {
      // Download the file from the URL
      axios({
        url: url,
        method: 'GET',
        responseType: 'arraybuffer',
      })
        .then((response) => {
          const data = new Uint8Array(response.data);
			console.log(`Start Project File  ${fileName} Download`);
          fs.writeFile(filePath, data, (err) => {
            if (err) {
              console.error(`Error downloading ${fileName}: ${err}`);
              reject(err);
            } else {
              console.log(`Download of ${fileName} complete`);

              // Extract the file to the specified folder
              const zip = new AdmZip(filePath);
              zip.extractAllTo(extractToPath, true);

              console.log(`Extraction of ${fileName} complete`);

              // Delete the downloaded zip file
              // fs.unlinkSync(filePath);

              resolve();
            }
          });
        })
        .catch((error) => {
          console.error(`Error downloading ${fileName}: ${error}`);
          reject(error);
        });
    }
  });
};

and at last :

const axios = require("axios");
const baseURL = '.../api/v1';

async function updateStatus(statusRender, jobUid, time, error = null) {
    try {
        const response = await axios.patch(`${baseURL}/user-project-output/update-status/${jobUid}`, {
            statusRender: statusRender,
            error: error,
            time: time,
            server: ''
        });

        if (response.data.status === 'success') {
            console.log(response.data.message);
        } else if (response.data.status === 'error') {
            console.log(response.data.message);
        }
    } catch (error) {
        console.error(error);
    }
}

module.exports = { updateStatus };

please help me.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.