Static Port for Azure Web Role in Dev Fabic - azure

How do I get my Azure Web Role to always use the same port when I run the solution instead of always incrementing the port by one?

I assume you're talking about running locally in the WA Simulation Environment. If so, it tries to use the port you specified (usually 80) and increments the port number by one at a time until it finds a free port.
If the port keeps increasing every time you run, it means the port is not getting freed up when you shut down your app. First, make sure you're actually stopping the previous run (open up the "dev fabric" or "compute emulator" depending on which SDK version you're using, and be sure to stop the old run). Second, you should be able to reclaim all those old ports for good if you shut down the dev fabric (compute emulator). You can do that by right-clicking the system tray icon and shutting down, or do "csrun /devfabric:shutdown" from the command line.

Related

Does an opened SSH connection to a GCLoud VM prevent it from freezing/crashing?

I have a f1-micro gcloud vm instance running Ubuntu 20.04.
It has 0,2 vcpus and 600mb memory.
I write freezing/crashing which stands for just not responding to anything anymore.
From my monitoring i can see that the cpu is at its peak at 40% usage (usually steady under 1%), while the memory is always arround 60% (both stats with my (nodejs) server running).
When i open a ssh connection to my instance and run my (nodejs) server in background everything works fine as long as i keep the ssh connection alive. As soon as i close the connection it takes a few more minutes until the instance freezes/crashes. Without closing the ssh connection i can keep it running for hours without any problem.
I dont get any crash or freeze information from gcloud itself. The instance has a green checkmark and is kind of still running. I just cant open a new ssh connection and also the only way to do something again with this instance is by restarting it.
I have cloud logging active and there are also no messages in there.
So with this knowledge my question is if gcloud somehow boosts ssh connected vms to keep them alive?
Cause i dont know what else could cause this behaviour.
My (nodejs) server uses arround 120mb, another service uses 80mb and the gcp monitoring agent uses 30mb. The linux free command on the instance shows memory available between 60mb and 100mb.
In addition to John Hanley and Mike, You can edit your Machine Type based on you needs.
In the Google Cloud Console, Go to VM Instance under Compute Engine.
Select Instance name to open its Overview page.
Make sure to Stop the Instance before editing Instance.
Select Machine Type that match your application needs.
Save.
For more info and guides you may refer on link below:
Edit Instance
Machine Family Categories
Since there were no answers that explained the strange behaviour i encountered.
I also haven't figured it out but at least my servers wont crash/freeze anymore.
I somehow fixxed it by running my node.js application in an actual background job using forever instead of running it like node main.js &.

Google VM - process persistence

I have a Google VM, and i can start a web server. The command i issue is: python server.py.
My plan is to have the application running.
Since i will eventually close my pc (and thus the terminal), will the application continue running normally?
Or, do i have to start the server and then use disown, to make the app run in the background?
NOTE: If the second option is the case, does this mean that when i re-log in, and i want to shut down the server, the only way to do it is with pkill?

How is a node application run when it is being deployed?

When you are writing a node application on your computer, you can run it from your computer by typing in node . However, how does that happen when the application is being deployed.
When you are writing a node application on your computer, you can run it from your computer by typing in node . However, how does that happen when the application is being deployed.
Basically the same way: there's not much of a difference between your computer and a computer in a data center. Either way, you start the process and it runs. It binds to a port that must be open, and then some firewall must be configured to allow incoming connections from the Internet to reach that port.
How you start the process in your "deployed" application varies greatly and is up to your needs and taste. You can:
1) Provision a server somewhere, install node on there, put your code there, and then run your application. You run it in the same way as your local computer. Log in to the computer and execute node. Or you can set it up to run with a process manager.
2) Use a PaaS like Heroku.
3) Use a serverless environment like Google Cloud Run.
You have many options and I'd explore them all!

Kill windows process that keeps restarting

I am trying to stop a windows service that is using a port I need, but the service keeps restarting it self. How do I stop it from restarting itself?
I followed this question to kill it (How to kill the process currently using a port on localhost in windows?), but when I listen for the port again a new service started already:
How this happened and some notes:
I created a Nodejs service and started it as a windows service (so now it is running in it's own windows instance)
My service had a cmd line to stop it self net stop "Service Name". This semi-failed for some reason (it did stop, kinda, but then it starts again)
I have even uninstalled the Nodejs service completely, but still something is starting it up over and over (because the port stays in use)
I can't move the Nodejs service files, because they are in use
To find out what application/service the PID is referring to, you can open Resource Monitor by running: resmon
Then choose CPU tab and look for the PID, Note: it could be under Processes or Services. If it's a service then you can stop and disable it so it won't run again.
If it's a Process, the name should give you an idea what it is.

linux -- determine what service was running on a down port

I need to write a bash script that:
-- takes ip address and list of ports as standard input,
-- check to see if port up or down,
-- if port is down, then restart the service via ssh
Got the first two working, however I am stuck on the last part, determining what service was running on the down port, as I may not know what services the machine is supposed to be running. lsof, netstat are not useful because the service is down.
The assumption is that this script will run on the users machine to check server status and restart any downed services automagically. It is known that some services may use ports listed in /etc/services for other services (for example, cpanel customer portal uses 2083, which /etc/services lists as radsec).
Any help is most appreciated, thank you!!
There is no way to determine what nonstandard ports what a non-running application may have used. All that you can do is to check for services which are not running, and (perhaps) restart those that are not running.
Even doing that runs into problems:
some services may not be running for other reasons (than loss of connectivity)
some services may not give a useful status when asked if they are running (Apache Tomcat, for instance, seems to come with service scripts which never do more than half the job).

Resources