Updating files when deployed (Django/Python) - django

I am trying to update files on a project that already has been deployed. The changes are not taking place when seeing it deployed, though when I sudo vim these files via GitBash, it shows the changes. Here's how I did when I'm logged into the server Ubuntu via AWS.
cd into the project
git add .
git commit -a -m "message"
git pull origin master
(it comes out a Nano screen--so I input a message then Ctrl X and then respond "no") and it shows the changes through vim.
There's no changes when I refresh the deployed project, and not even when I reboot it via AWS. Can someone please share the steps to make changes and show changes on a deployed project? Thank you so much, I appreciate your feedback!

You need to restart the service running your app to update the app:
sudo systemctl restart service_name

Related

Automatic scheduled git pulls on a GCP server running a flask website

I had a few questions about automatic git pulls on a remote server. I am aware there are several questions like this, but I wasn't sure what steps to take exactly, and I don't want to mess up my current setup with a mistake :/
To wit, the environment is on a Google Cloud VM. I am running a flask-based website that renders each page with the render_template() function.
The website resides inside its git folder, i.e. I never set up a bare repo and copied stuff. When I set it up a couple years ago, I just did git clone repo-url, then inside the repo directory, did flask run. Then I set up nginx to connect to the site's socket created with uwsgi inside the repo directory.
--
It has been working fine. I make changes locally to the content, push to github, then log in to the VM, and perform a git pull.
I want to do this automatically. I tried adding a cron job to do this, where the job basically ran a script, and the script did the git pull. Script content was:
cd /repo
git pull
Running the script in the server worked, but cron never managed to do the pull.
--
I have been reading about web hooks, and there is a bunch of stuff about post-receive hooks, post-update hooks, and making bare repos. At this point, I am embarrassed to say I have no idea what I should be doing.
Any help is greatly appreciated.
Another option would be to consider a GitHub Action, which, from GitHub, could interract with your Google cloud VM.
For example, actions-hub/gcloud.
- uses: actions-hub/gcloud#master
env:
PROJECT_ID: test
APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
with:
args: cp your-file.txt gs://your-bucket/
cli: gsutil

How can I edit a Django project in Ubuntu EC2 after it was cloned from Git?

I created an Ubuntu EC2 instance and uploaded my Django project (formerly uploaded to git) by following the steps used in the YouTube tutorial here. The Django project worked fine on my local computer using the 127.0.0.1:8000 url & port. I want to keep developing it on the Ubuntu EC2 instance, but after adding a new url, view, and template, the project breaks. As a test, I copied edits and new files back to my local computer and tried to recreate the problem, but it worked fine. Is it not possible to edit Django projects on Ubuntu EC2? Will I have to solely develop in Git and re-push to EC2 every time I want to updated my website?
Thanks!
You only need to restart gunicorn:
systemctl restart gunicorn
you only need to restart nginx when you change any related nginx configurations
I was able to figure it out - it is necessary to restart nginx and gunicorn after making changes with the following code:
sudo service nginx restart; sudo service gunicorn restart

How do you restart logstash on an AWS server?

This is a pretty basic question, but I coiuld nto for the life of me find a straight answer about it on google.
I have logstash/Kibana/Elastisearch installed and working on an AWS server. Due to some complications, logstash stopped sending files to Kibana, and I wanted to restart it to see if it would fix the issue. (This is on an Ubuntu 14.04.2).
All of the commands I looked up on google would not restart the service properly. If I check the services running, logstash is on that list and has a -.
restart logstash gives the error "Unknown job: logstash", and some of the others I found gave a similar kind of error.
What is the proper command to run in order to restart logstash?
if you installed .deb or .rpm package then you can restart using command
sudo service logstash restart
or
sudo /etc/init.d/logstash restart
or
sudo service logstash stop
sudo service logstash start
if you logstash creating problem to starting or stoping then you can start it manually also
go to /opt/logstash/bin and run logstash script (logstash.bat for window)
cd /opt/logstash/bin
./logstash -f logstash-simple.conf
logstash-simple.conf is your logstash config file you can change it to any name
or
if you downloaded .zip or any other compressed file then go that path and run same way.

Jenkins can't copy files to windows remote host

I have a Jenkins server on OS X 10.7, which polls a subversion server, builds the code and packages the app. The last step that I need to complete is deploying the app on a remote host, which is a windows share. Note that my domain account has write access to the target folder and the volume is mounted. I've tried using a shell script build step:
sudo cp "path/to/app" "/Volumes/path/to/target"
However i get a "no tty" response. I was able to run this command succesfully in Terminal, but not as a build step in Jenkins.
Does this have something to do with the user being used when starting up Jenkins? As a side note, the default user.name is jenkins and my JENKINS_HOME resides in /Users/Shared/Jenkins. I would appreciate any help as to how to achieve this.
Your immediate problem seems to be that you are running Jenkins in the background and sudo wants to input a password. Run Jenkins in the foreground with $ java -jar jenkins.war.
However, this most probably won't solve your problem as you'll be asked to enter a password when the command runs - from the terminal you started Jenkins from (presumably it's not what you want). You need to find a way to copy your files without needing root permissions. In general, it it not a good idea to rely on administrative permissions in your builds (there are exceptions, but your case is not it).

New deployment does not show up with capistrano/passenger command-line

I make a change on the local server (something obvious, removing a <h1/>). I see it on the local machine. I then commit and push the changes and do cap deploy.
I do not see the changes when I access my staging environment.
I checked the following: Capistrano does not give me an error. I ssh onto the server and in the code, the change IS there. I restart the server manually by sudo touch tmp/restart.txt, but still I cannot see the change in the browser. Symbolic links from current/ point to the correct revision folder.
What can be causing this? The only thing I'm doing non-standard I think is that I do not deploy in production, but rather in environment called dev2. So my server start command is sudo passenger start -e dev2 -p 80 --user=ubuntu (btw, how should I deploy passenger in production? passenger start always deploys it in development, for some reason).
So to summarize, when I deploy with capistrano, I don't see the changes, although the server is restarted and the codebase does have the changes.