Controlling Gunicorn in a new ssh session - django

I am using Gunicorn to power Django application on a remote server (ubuntu), to which I connect by ssh. Once Gunicorn has started the status log pops up showing you what is going on and such. However when I close my ssh session and reconnect later on I cant seem to reopen the process without killing Gunicorn and rebooting the server.

Not sure if i understand your issue correctly...
When running django/gunicorn usually it is helpful to use some tools to control the processes. One really good option to do so is the use of supervisord:
http://docs.gunicorn.org/en/latest/deploy.html#supervisor
If you just want to run processes directly and being able to (dis-)connect - generally screen is a good option.
It allows you to to disconnect an ssh-session while leaving your 'virtual?' terminals running.
Just re-ssh to your server and reconnect using:
screen -xr

Related

Google Compute Engine goes to sleep after some time

I'm trying to run my application on GCE VM. It uses nodeJs as frontend and a Java backend. I use this server to communicate with my local computer using MQTT. This is working but after some time (one hour and a half), the server seems to go to sleep (or the ports close ?).
Both MQTT and ssh terminal interface connections are lost.
When I connect back, the application is not running anymore, it seems like the VM restarted.
Do you have any idea on how to keep my server alive ? I can give further details.
Answering my own question as John Hanley explained the solution in comments:
"By what method are you running your frontend and backend code. VMs do not go to sleep. If you are starting your software via an SSH session, that will be an issue. Your code needs to run as a service. Edit your question with more details."
I was indeed running my application via the ssh terminal which caused the problem. The solution for me was to remotely access the VM via vncserver and to launch the application using the VM's terminal.

Using plink commands from Rstudio with the AWS EC2 has disabled the instance DNS

I was trying to process GWAS data using plink1.9 with a rental AWS ubuntu server. I executed the plink commands from the terminal window in the Rstudio server.
It turned out that if I execute a plink command that overloads the server, my Rstudio server will become inaccessible and this problem does not revolve.
for example my Rstudio-server from port 8787 has become unavailable.
http://ec2-54-64-41-xxx.ap-northeast-1.compute.amazonaws.com:8787/
I accidentally did it twice. First time I did something like cat xxx.vcf (how stupid of me) and the server simply went frozen and the Rstudio server crashed.
Since I could still access the server with putty and winscp and so on I managed to get my files to a new instance. Then I tried to use plink to do some QC, something like
./plink --bfile xxx--mind 1 --geno 0.01 --maf 0.05 --make-bed --out yyy
It had again overloaded the server and the same Rstudio server trouble occurred again.
Now both instances are still accessible from putty, I logged on to check the running processes and it seemed to be fine. There were no active heavy jobs and no zombie processes either.
The CPU monitoring looks fine too.
With the only problem that the Rstudio-server link is not working.
Does anyone have similar experiences? Your advice is very much appreciated.
mindy

Promise Technology VTrak configure webserver

I inherited management of some Promise VTrak disk array servers. They recently had to be transferred to a different location. We've got them set up and networking is all configured, and even have a linux server mounting to it. Before they were transferred I was trained with the web gui it comes with. However, since the move we have not been able to connect to the web gui interface.
I can ssh into the system and really do everything from there, but I would love to figure out why webserver is not coming up.
The VTRAK system does not allow for much configuration it seams. From the CLI I can start, stop, or restart the webserver, and the only thing I can configure is the amount of time someone can be logged into the gui for. I don't see anywhere where you can configure http or anything like that.
We're pretty sure it's not a firewall issue as well.
I got the same issue this morning, and resolved it as follows:
It appears there are conditions that can render the WebPam webserver with invalid configuration HttpPort and HttpsPort values. One condition that causes this is if the sessiontimeout parameter exceeds 1439 set in the GUI. Apparently the software then freaks and creates invalid configuration which locks out the GUI because the http ports have been changed to 25943 and 29538.
To fix this login through CLI:
swmgt -a mod -n webserver -s "sessiontimeout=29"
swmgt -a mod -n webserver -s "HttpPort=80"
swmgt -a mod -n webserver -s "HttpsPort=443"
swmgt -a restart -n Webserver
You should now be able to access the WebPam webserver interface again through your web browser.
After discussing with my IT department we found it was a firewall issue.

Quit Django dev server but process doesn't stop

I'm developing on Mac OSX 10.8. Lately I've been noticing that when I've been running the dev server for a while, and then -C to exit, the process continues to run in the background. I have to do a ps to find the process and kill it, or it won't let me use the same address:port again.
I didn't have to do that in earlier versions of Django (I'm currently running 1.7.3 on this project). Seems a bit messy, but don't know of another way to stop the dev server and free the port/resources?
Rgds,
Ross.
Django development server have multiple threads, so when closing main process, there might be some running threads in background. It happens when there is some request being processed (some long-term request can hang or if you're using websockets or something, connection might prevent closing thread).
Check if all of your requests are properly closed before closing your server and it should shut down properly.

Custom django runserver command which establish ssh tunel before running server

My application use database which is on another server. To increase security, access to db server was restricted only for specified production servers.
However sometimes I need to have access to this db, when running development environment from my localhost.
For now a simply run in another console before running server:
ssh tunnel#server-with-access-to-db.com -L 12345:localhost:3306
..which works great, however I need to remember to do that.
I am wondering how to write custom runserver which will establish tunnel automatically, and what is important, will close that tunnel after server will be shut down.
I know that in the future VPN will be much better, however it is not possible for now.
I will be grateful for any suggestions.
FYI: one part of writing custom runserver command is extending it. You can use this example to do so.