I am trying to deploy Django based website on AWS EC2. I have successfully created an instance and install my python libraries there. I am using Postgres here. For that, I have installed Postgres along with pgAdmin, but for some reason, it does not open. It just displayed that it's starting up the server but it does not open at all.
I am new to it so I do not know much about it. Can someone please help or guide me why it does not open up?
You will need to check the logs from
C:\Users\Administrator\AppData\Local with name - 'pgadmin4.startup'
A lot of the time removing the instance and recreating usually works but without seeing the logs it's hard to tell what the issue might be. Could also be worth making the instance a bit beefier as pgadmin does use a good amount of CPU and memory.
Related
My project which runs in Cloud Run of Google Cloud Platform (GCP) has generated errors: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 68387105408768 and this is thread id 68386614675200. for hours before it went back to normal by itself.
Our code is written in Python with flask & no SQLite is involved. Saw suggestions to set check_same_thread to False. May I know where I can set this in Cloud Run or GCP? Thanks.
That setting has nothing to do with your runtime environment, but is set during the connection initialization with sqlite (https://docs.python.org/3/library/sqlite3.html#module-functions), so if you claim that you aren't creating an sqlite connection that won't help you much.
That being said, I find it hard to believe that you are getting that error without using sqlite. More likely is that you are using sqlite via some dependency.
Since sqlite3 is part of the standard library of python it might however not be trivial to figure out which dependency uses it.
Similar question was asked here, however the solution does not give the shell access to the same environment as the deployment. If I inspect os.environ from within the shell, none of the environment variables appear.
Is there a way to run the manage.py shell with the environment?
PS: As a little side question, I know the mantra for EBS is to stop using eb ssh, but then how would you run one-off management scripts (that you don't want to run on every deploy)?
One of the cases you have to run something once is db schema migrations. Usually you store information about that in the db... So you can use db to sync / ensure that something was triggered only once.
Personally I have nothing against using eb ssh, I see problems with it however. If you want to have CI/CD, that manual operation is against the rules.
Looks like you are referring to WWW/API part of Beanstalk. If you need something that is quite frequent... maybe worker is more suitable? Problem here is that if API goes deployed first you would have wrong schema.
In general you are using EC2, so it's user data stores information that spins up you service. So there you can put your "stuff". Still you need to sync / ensure. Here are docs for beanstalk - for more information how to do that.
Edit
Beanstalk is kind of instrumentation on top of EC2. So there must be a way to work with it, since you have access to user data of that EC2s. No worries you don't need to dig that deep. There is good way of instrumenting your server. It is called ebextensions. It can be used to put files on the server, trigger commands, instrument cron. What ever you want.
You can create ebextension, with container_commands this time Python Configuration Namespaces section. That commands are executed on each deployment. Still, problem is that you need to sync since more then one deployment can go at the same time. Good part is that you can set env in the way you want.
I have no problem to access to the environment variables. How did you get the problem? Try do prepare page with the map.
I've never worked with Django before so forgive me if a question sounds stupid.
I need to develop a web application, but I do not want to deploy it on a server. I need to package it, so that others would "install" it on their machine and run it. Why I want to do it this way? There are many reasons, which I don't want to go into right now. My question is: can I do it? If yes, then how?
This is possible. However, the client machine would need to be equipped with the correct technologies for this to work.
When you launch a web app on a server (live), the server is required to have certain settings and installs. For example, a Django web app: the server must have a version of Django installed.
Hence, whichever machine is running your web app, must have Django installed. It presumably also needs to have the database too. It might be quite a hassling process but it's possible.
Just like as a developer, you may have multiple users working on 1 project. So, they all need to have that project 'installed' on their devices so they can run it locally.
You need to either use a python to executable program, with Django already in it. The website files you can place into the dist folder or whatever folder has the executable in it. Then you can compress it and share it with others (who have the same OS as you).
For an example:
You have this script in Django (I'm too lazy to actually write one), and you want to share it with someone who doesn't have Python and Django on his/her computer.
How can I update a python script remotely. I have a program which I would like to share, however it will be frequently updates, therefore I want to be able to remotely update it so that the users do not have to re-install it every day. I have already searched StackOverflow for an answer but I did not find anything I could understand. Any help will be mentioned in the projects credit!
A very good solution would be to build a web app. You can use django, bottle or flask for example.
Your users just connect to your url with a browser. You are in complete control of the code, and can update whenever you want without any action on their part.
They also do not need to install anything in the first place, and browser nowadays provide a lot of flexibility and dynamic content.
I have looked and I could not find this question before, and it surprises me.
I am reasonably proficient in Python, and I used Dreamhost for a number of years. Now I would like to learn Django. They are finally supporting it using Passenger. Which I do not know what is.
Following the instructions on Dreamhost I installed Django. Then I started following the tutorial 01. This went well, except that I could not start the server (this in the tutorial) since the code was live on dreamhost. At the time this did not seem to make any difference. Then when I went on the second part of the tutorial I had to access the admin site. And it worked well going to myurl/admin/ , as it should. But here the problems started. According to the tutorial (here) I have to add a file in the poll application and then restart the server. But I never started the server in the first place, my code is running live on the web... but when I add a file the website the admin acts as if it does not see it.
Probably dreamhost has started its own server, and I don't know how to restart it. But I assume this is going to be a common problem when you run django on dreamhost. Every time you add a file you will have to tell the server to consider it.
So what should I do to let the server know about it?
Thanks,
Pietro
Here's the relevant section of the Passenger user's guide for restarting Passenger:
http://www.modrails.com/documentation/Users%20guide.html#_redeploying_restarting_the_ruby_on_rails_application
Eventually I got the answer from the DH support service. They told me to
pkill python
I did it. I also checked with
ps -aux
what process I was running. And indeed I could see the python process starting when I went to the page, and being killed when I pkilled it.
Thanks for all that helped.
I had the same problem with Passenger not reloading the Django server.
According to Django wiki page on Dreamhost, you can touch a "restart.txt" file that Passenger watches. If the timestamp on the file changes, Passenger restarts Django.
If you modified your application and your changes do not seem to be reflected, you may need to notify Passenger about your change by creating or modifying ~/example.com/tmp/restart.txt:
touch /home/user/example.com/tmp/restart.txt
Source: http://wiki.dreamhost.com/Django#Hints
For the tutorial, you should be working on a local machine, not a web server.