none
[Node.js][Web Apps] WebJob continuously restarting RRS feed

  • Question

  • I know exactly why this is happening.  My question is if there is a way to *exclude* a directory that is watched within a WebJob.  I'm writing a very small amount of data to a log directory within the WebJob folder structure.  I'd like to continue doing that.  Is there a web.config setting that I can use to exclude this log directory?  This is a NodeJS web app.

    Log Output given from Azure:

    [03/25/2016 14:14:55 > 8c7c50: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
    [03/25/2016 14:14:55 > 8c7c50: SYS INFO] Status changed to Stopping
    [03/25/2016 14:15:00 > 8c7c50: ERR ] Thread was being aborted.
    [03/25/2016 14:15:00 > 8c7c50: SYS INFO] WebJob process was aborted
    [03/25/2016 14:15:00 > 8c7c50: SYS INFO] Status changed to Stopped
    [03/25/2016 14:15:00 > 8c7c50: SYS INFO] Status changed to Starting
    [03/25/2016 14:15:00 > 8c7c50: SYS INFO] Run script 'index.js' with script host - 'NodeScriptHost'
    [03/25/2016 14:15:01 > 8c7c50: SYS INFO] Status changed to Running
    [03/25/2016 14:15:05 > 8c7c50: SYS INFO] Detected WebJob file/s were updated, refreshing WebJob
    [03/25/2016 14:15:05 > 8c7c50: SYS INFO] Status changed to Stopping

    If I stop writing to the log file, the WebJob performs as expected and the process doesn't restart.


    Cheers, Matt Bramer
    My Blog
    Send me a tweet



    Friday, March 25, 2016 2:28 PM

Answers

  • What's strange is that normally, the WebJob doesn't run inplace, but instead gets copied to a temp folder. So I would think that if you write something in a folder relative to where your WebJob is running from, you'd end up writing in the temp folder, which would not restart it. Only changes to D:\home\site\wwwroot\App_Data\jobs\Continuous\JobName cause a restart.

    Can you check the full path of the folder that your log file is in?

    • Marked as answer by iOnline247 Friday, March 25, 2016 4:32 PM
    Friday, March 25, 2016 3:36 PM

All replies

  • What's strange is that normally, the WebJob doesn't run inplace, but instead gets copied to a temp folder. So I would think that if you write something in a folder relative to where your WebJob is running from, you'd end up writing in the temp folder, which would not restart it. Only changes to D:\home\site\wwwroot\App_Data\jobs\Continuous\JobName cause a restart.

    Can you check the full path of the folder that your log file is in?

    • Marked as answer by iOnline247 Friday, March 25, 2016 4:32 PM
    Friday, March 25, 2016 3:36 PM
  • The directory is within the WebJob directory, meaning it's writing within the: D:\home\site\wwwroot\App_Data\jobs\Continuous\JobName\Logs path.  

    I haven't tried writing to a log directory elsewhere.  I'll give that a go and see if I get better results.


    Cheers, Matt Bramer
    My Blog
    Send me a tweet


    • Edited by iOnline247 Friday, March 25, 2016 4:02 PM wrong directory name
    Friday, March 25, 2016 4:00 PM
  • Based on my testing, having the "logs" directory within the path where the WebJob runs, it'll restart the job every time a file changes.  I just changed the path to the root using:

    const logDirectory = path.join(process.env.WEBROOT_PATH, 'logs');

    And the job isn't restarting every time.  Thanks for the sanity check!


    Cheers, Matt Bramer
    My Blog
    Send me a tweet

    Friday, March 25, 2016 4:34 PM
  • Hmmm, I'm actually surprised that changing a sub folder of the WebJob doesn't cause it to restart. You might also consider logging to %HOME%\LogFiles\SomeFolderOfYourChoice.
    Friday, March 25, 2016 4:39 PM