Skip to content

ulysse-lacour/Homeworks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HOMEWORKS CLUB :)



Gunicorn

  • Create service file :
sudo nano /etc/systemd/system/my_project.service

Add :

[Unit]
Description= description_text_you_want
After=network.target

[Service]
User=user_name
Group=www-data
EnvironmentFile=.env_file_absolute_path
Environment="PATH=virtual_env_path"
WorkingDirectory=app_working_directory
ExecStart=gunicorn_path --workers 3 --bind unix:my_project.sock -m 007 project.wsgi:app

[Install]
WantedBy=multi-user.target
  • To find virtual env path and gunicorn path use :
which gunicorn
  • Start and enable app :
sudo systemctl start my_project
sudo systemctl enable my_project
  • Check for status app :
sudo systemctl status my_project
  • To restart app :
sudo systemctl daemon-reload
sudo systemctl restart my_project


Nginx

  • Create server block :
sudo nano /etc/nginx/sites-available/my_project
  • Add :
server {
    server_name IP adress or domain nam;

    access_log /path_to_myproject/logs/access.log;
    error_log /path_to_myproject/logs/error.log error;

    location / {
        proxy_pass http://unix:path_to_myproject/my_project.sock;
        include proxy_params;
    }
}
  • Link to sites-enabled :
sudo ln -s /etc/nginx/sites-available/my_project /etc/nginx/sites-enabled
  • Check for syntax errors :
    sudo nginx -t
  • Restart nginx :
sudo systemctl restart nginx

Or you can restart nginx with bash ~/restart_nginx.sh



Bash scripts and alias

For each project you cand add to ~/.profile :

alias my_project-log="sudo journalctl -u my_project -n 150"
alias my_project-reboot="sudo systemctl daemon-reload && sudo systemctl restart my_project"
alias my_project-status="sudo systemctl status my_project"


Import csv to database

  • Connect with superuser :
sudo -u postgres psql
  • connect to databse :
\c databse_name
  • copy :
COPY table_name FROM 'absolute_path_to_csv_file' delimiter 'delimiter' csv header;

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published