So I have a rest server, in Java. Sometimes the server can crash because of problems or errors in Java, memory outage and more. My problem is that I want this server to always run even after it crashes. Whenever the machine is running, I need the server to run. I know about cron jobs but I am thinking of many scenarios that this would fail. Are there better practices?
Ideally You should handle all the error scenarios . Memory management has to be done by the programmer.
In case you want to start your service whenever machine is started, You can put those scripts in the startup services available in each platform(Linux,Windows) . This will make sure that your service will be started automatically after every restart of machine.
To handle failures, its better to setup alarms Example: Send out an email when memory is full or automatic kickoff of scripts to clean up.
Related
In Azure DevOps Pipeliens, when deploying an app to Functions, the app may restart during the process of the app.
Is there a way to monitor if the Functions app is running in the pipeline, make sure it's done, and then deploy the app?
Conditions
Functions runtime: Java
Trigger: Service Bus Trigger
I tried to check the lock status of Service Bus messages or the processing status of the Functions app with the Azure CLI, but it seems that there is no interface to check the processing status.
https://learn.microsoft.com/en-us/cli/azure/functionapp?view=azure-cli-latest
https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest
You should never rely on that better build your functions to execute fast.
When Azure function sends signal to stop in c# we have CancellationToken this way we can have extra code to implement shutdown, otherwise as soon as AF get signal to stop it will not accept new events from service bus but will continue to execute current functions, and if they wont stop for some time they can be terminated (cant find exact time but will update answer )
I would also suggest you to utilise deployment slots this way you can minimise your downtime.
I have a Spring Boot app (jar file) that is running on Windows server and is used to sync data between some tables in a database and other parts of infrastructure (consumer apps via ActiveMQ).
It is crucial to have it running 24/7 without any downtime (or with very little).
I am currently trying to find the best way to do this as our current solution is to run multiple instances of the same app and define one to be active and ping it continuously (via an entry in database where it writes every 15 seconds), while other instances are just running and do nothing (inactive state, cause lock is taken). If an active instance has stopped to update lock entry (freeze or crashed) in database one of the available instances will take its place and start to handle data.
I have a feeling, that it is not so flexible solution, especially when I need to prepare different part of my code to check lock entry and sync all those instances. It adds complexity to the code and I want to avoid it.
Is there any better solution? Plugins, implementation pattern or tools?
PS:
I read about health endpoints that are available in a SpringBootApplication and think that it can help me somehow (ping\check them from some other Watchdog software\tool, maybe?), but don't know how.
In case of a crash you still have a delay of 15 seconds while a request can fail
I would go with a zuul router from netflix (open source)
It will balance the load between instances and will retry your request on another instance if the first call has failed
I'm pretty sure it's already done but use windows services to restart instance in case of hard crash
We have multiple java web applications and processes that are deployed on a server. we would like to find a mean to easily monitor these applications and check their status remotely. by motoring we mean the following :
Check if the websites are up, send notifications by email otherwise.
Easily access or display logs in real-time that are located in different places on our servers. Send emails when exceptions occurred and are logged
Issue commands and run scripts that are located on our servers. the os of the server is linux. commands could be like restart tomcat...
? not sure if there are other ideas about monitoring
My question is that is there any application that is already available that provide such functionalities or some of them? if not do you know what API can be used to build such applications (in JAVA).
UPDATE:
The tool should be free
Thanks in advance for any help!
For monitoring Java applications as well as website availability, issuing custom commands in your servers and in general, monitor applications go for a general-purpose monitoring solution, like Pandora FMS. I'll try to answer your questions in order:
Check if the websites are up, send notifications by email otherwise.
Doing a network check to TCP port 80 and parsing a 200 OK response.
Easily access or display logs in real-time that are located in different places on our servers. Send emails when exceptions occurred and are logged
Easy thing to do with the log retrieval feature. Check it out in the wiki.
Issue commands and run scripts that are located on our servers. the os of the server is linux. commands could be like restart tomcat...
I'd suggest using Pandora Agents in this case. Quite powerful, yet very low resource consumption. They allow to do post-actions if your app is down, your CPU is high, or in general terms, anything you can measure happens. Check out the server monitoring more deeply: http://pandorafms.com/monitoring-solutions/server-monitoring/
On Linux, you an use monit. You can use it to any monitor services such as apache as well as wildfly running behind apache. It is actually easy to configure and it also gives all that you have requested.
If you want to monitor java processes, there is nothing better than MoSKito: http://www.moskito.org.
The only problem is that it covers much more, than you stated as your requirements, you will also get:
health thresholds and notifications
detailed performance metrics of your java code
dashboards with most important information about your app
mobile applications to monitor your app on the run
detection of slow transactions in your application
and more more more ;-)
http://www.moskito.org
http://newest.moskito.org/moskito/ (nightly build of the UI)
Step by Step guide: http://blog.anotheria.net/msk/the-complete-moskito-integration-guide-step-1/
We are in the process of creating a training mode for our ColdFusion (9) sites.
The system will allow our users, after logging in, to switch from production mode to training mode by clicking on a link.
When they switch, the data-sources will be switched allowing the data to be safely modified.
We are also going to implement a test SMTP server, using the SubEthaSMTP Java project, in order to capture the emails that are sent from the training mode and display them to the user in a web page.
We can launch the SMTP server as a stand alone process or service without much trouble.
The nicer solution would be to launch server as part of the ColdFuson runtime at the point that the user switches to training mode.
We would create a true Java thread that would persist on a Server level scope for the length of any training sessions and then some arbitrary time out period. If the server times out and a new training session is initiated we would initiate a new SMTP server.
My essential question is, therefore, is it a bad idea to run an ongoing thread in the ColdFusion runtime this way?
I can't see a problem with doing this, although you ought to test to see what resources SubEthaSMTP uses and make sure it's not going to cause you issues. It looks to have minimal dependencies (essentially just SLF4J, which ColdFusion 9 & 10 already provide)
From the example page it looks to be pretty easy to set up and drop into a long-running scope. I think you're right to pick the server scope, as you may have problems using application or anything more volatile, as there'll be a situation where application scope would timeout and be reset, but you'd loose all references to the Mail Server instance.
Please update the post with your findings, as I'd be interested in seeing what you find.
Is it possible to invoke an exe on a remote computer, supposing we know the absolute path of the exe where it lies?
I have written a client and a server program and am able to get both work as expected when both are running. But now, all I want to do is to invoke the server program from client if server is not running. Seems like defeating the purpose of server-client model but still.
If that is possible without knowing the login credentials of the remote system, then it'd be cool. Eg: There are softwares like 'PsExec' that need login credentials.
I understand that, such a feature may not be there, as it would mean a serious security threat, but, I am just wondering if there is some sort of a workaround.
If that is possible without knowing
the login credentials of the remote
system, then it'd be cool. Eg: There
are softwares like 'PsExec' that need
login credentials.
I understand that, such a feature may
not be there, as it would mean a
serious security threat, but, I am
just wondering if there is some sort
of a workaround.
Those "inconvenient" security rules are there for a purpose. You simply do not want people to be able to run any old program on your machine without proper authentication and authorization. Not even if you are behind a firewall.
Why?
In one word - Viruses! If some machine on your network gets infected with a virus (or similar malware), then all machines that run a non-authenticated remote execute service would be at serious risk of infection.
Try Gridserver technologies... it's based on grid technology and very efficient and easily deployable.
You could setup a messaging system like a remote procedure call, webservice, or simple tcp socket on the server to do a wake up on the server process.
The only way you can execute an exe is by executing a local application which you have access to. There must be a part of the software running on the computer you want to execute an application on. From there, you can do a remote call from a second program on a remote machine asking the local one to do his job : execute.
As stephen C said, it would be a violent breach of security if I could run exe on your machine without your permision.