Save Logs on Heroku with Node - node.js

I'm trying to find a way to store logs so that they can be seen in my website.
I have a website hosted in Heroku, where I use a package like Winston to save logs to a .log file. The problem occurs when using this system in Heroku, as when the dyno restarts every day, the log file gets deleted and a brand new .log file is created.
What would be the best way to store all these logs without them being lost on a dyno restart?
PD: I don't monitor logs but I just want a simple way of storing logs to be viewed by people in my website. Right now it's done by reading the .log file.

One interesting option could be using Papertrail: there is a free plan and with it you get a REST API to query the logs (you can then customise what users see/download).
Papertrail has Heroku integration so pushing the logs from your application should be pretty simple. You can then query/export what your need implementing access via the REST API.
Heroku has also a Papertrail add-on which I think it is the same concept as above but running on Heroku cloud.
Obviously the free plan has a short data retention, you will need to see if this works for you.

Related

How to speed up slow Azure App Service Zip Deployment?

I am deploying a Nuxt application with Appveyor over Azure App Service Zip Deploy, but I am having trouble with the full deployment process being incredibly slow (Around 30+ minutes).
It seems that the whole build process is going as it should, but zipping the files takes around a minute or two (106 MB), and the file is successfully being pushed to the app service within a reasonable amount of time. However the incredible waiting time is at the Site Under Construction white page stage, taking down the whole website with it.
Does anyone have any tips to speed up this process besides upgrading
the App Service plan?
Is there any way to avoid the blank Site Under Construction page?
For example, is there a way to unzip to another folder and move the
files after everything is done so I would get minimal downtime on
the website?
You can add WEBSITE_RUN_FROM_PACKAGE=1 app settings
This option will deploy your app service to read only file system (read-only wwwroot folder, other folders are available for write operations)
Please take into account if you set this variable on ci/cd tool side probably the first time it won't apply because app settings are passed after zip deployment
And regarding the second questions. I guess it could be fixed by another app settings SCM_CREATE_APP_OFFLINE=0 (it should update your app without bringing it offline)

Azure App Services Web App not registering update

I have a Azure App Service app that I'm trying to get deployed.
Today I ran into an issue where .NET informed me (via the yellow screen of death when I browse to the URL of my app) that I had a missing DLL (for the purposes of this question I don't think it really matters).
I used FileZilla to publish my changes in an attempt to do a manual deployment first and then work my way to automate it.
After so many attempts to fix it I later realized that the error message never changed. I did something more severe and renamed my bin folder into something completely different and the exact same error message would appear.
I've stopped the service, restarted it, and as mentioned, renamed folders, etc. and still the exact same error message persisted.
I also decided to open up the Azure Portal Console for my App Service app to browse a bit and to my amazement, nothing seemed to have reflected at all. The FTP shows one thing and the Console shows another.
Would anyone have any idea as to why this is happening?
I eventually got it to work and I will share what I tried.
I deleted the web app and created it again (I found this to be important the first time around). This was quite time consuming and did help but it wasn't long before the same problem happened again.
Then I finally found a solution that seems to give me consistent results:
I kept on editing the Web.config which seems to force a recompile and clear some sort of cache. So each time the web app stopped updating, I would make a slight change in the Web.config, upload it via FTP and the app finally updates.
If anyone has any more details on this, it would be greatly appreciated.

How to reduce Azure web app temp file usage

I have a couple of small web apps hosted in Azure. I am using a shared app service, not VMs. Recently Azure has started showing warnings that I need to reduce my app's usage of temporary files on workers.
The link from the message doesn't provide anything useful for resolving this.
After restarting the app, the problem has gone away. Seems that temporary apps were cleared by doing a restart.
I am not sure what generated 179GB of temporary files and how I can reduce this. What should I look for? I am not explicitly storing anything in temporary files in code, data is stored in the database, so not sure what to look for.
The temp file usage is probably caused by one of your app that keeps creating temp files without cleaning them up. Restarting cleans up everything, but it's likely going to grow back over time if your app keeps doing the same thing.
There is no single solution to fix this. You'll need to figure out what causes this is your app logic, and change it to better clean up after itself.

How can I see the log of Spark job server task?

I deployed spark job server according https://github.com/spark-jobserver/spark-jobserver. Then I created a job server project, and uploaded to the hob server. While I run the project, how can I see the logs?
It looks like it's not possible to see the logs while running a project. I browsed through the source code and couldn't find any references to a feature like this, and it's clearly not a feature of the ui. It seems like your only option would be to view the logs after running a job, which are stored by default in /var/log/job-server, which you probably already know.

Azure website node process lifecycle

I 've found out that Azure websites (trial version) doesn't autostart my node sever process (it starts only when I load the url in the web browser); and that when there are no requests in a while, the process is killed.
I mean, when I git push my server, I would like it to start running immediately and continuously.
I read (here, for example) that this might have to do with the way iisnode manages azure websites, and that I can't do anything to change it. Is this the actual way Azure websites work? Is there any way I can deal with this?
Thanks in advance,
Bruno.
You've find the answer. There is no other answer.
The process termination because of inactivity comes from IIS - there is Idle Timeout setting. Which to my knowledge is not configurable in Azure Web Sites (at least not Free tier). Check out also this SO question and its answer to get better understanding on why you can't change this timeout on the FREE and STANDARD tiers.
And here is an interesting workaround to avoid this idle timeout. Actually if you use technique, you will also have kind-of "auto start", in terms that when your scheduler hits your site after a new deployment, it will "boot up".
This can get a little complicated, but if you don't want to use their 5-min ping service, you can keep these always on by doing the following:
Create an app setting on your website configuration tab within the portal:
WEBSITE_PRIVATE_EXTENSIONS and give it a value of 1
Create a text file named applicationhost.xdt and populate it with:
<?xml version="1.0"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"><system.applicationHost><applicationPools><add name="DefaultAppPool" managedRuntimeVersion="v4.5" startMode="AlwaysRunning"><processModel identityType="ApplicationPoolIdentity" /></add></applicationPools></system.applicationHost></configuration>
ftp into your website and create a folder on the root directory called Site Extensions. (there should now be 3 folders in your root: LogFiles, site, & SiteExtensions)
Create another folder within 'Site Extensions', named ASPLimits
Upload the applicationhost.xdt into the ASPLimits folder
Restart your website using the portal

Resources