Skip to content

Commit

Permalink
v1.0.10
Browse files Browse the repository at this point in the history
Minor bugfix and new config files
  • Loading branch information
Vineees authored May 2, 2024
2 parents f971125 + fd45576 commit c2577a0
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ DEBUG=
#django.db.backends.sqlite3 or django.db.backends.mysql
DBTYPE=
DBHOST=
#Set your database name
#If you are using sqlite use on DBNAME: BASE_DIR / 'db.sqlite3'
#Set your database name
#MySQL or SQLite3 (Case-sensitive)
DBNAME=
DBUSER=
DBPASSWORD=
Expand Down
25 changes: 25 additions & 0 deletions config/morea.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
#LISTEN PORT 80
listen CHANGE-PORT;
#YOUR DOMAIN OR IP
server_name CHANGE-DOMAIN;
#INCRESE THE MAX TRANSFER
client_max_body_size 32M;

location / {

proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#STATIC LOCATION
location /static/ {
alias CHANGE-STATIC;
}
#MEDIA LOCATION
location /media/ {
alias CHANGE-STATIC;
}
}
}
25 changes: 25 additions & 0 deletions config/nameservice.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#/etc/systemd/system/nameservice.service

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
Type=notify
# the specific user that our service will run as
User=someuser
Group=someuser
# another option for an even more restricted service is
# DynamicUser=yes
# see http://0pointer.net/blog/dynamic-users-with-systemd.html
RuntimeDirectory=gunicorn
WorkingDirectory=/home/someuser/applicationroot
ExecStart=/usr/bin/gunicorn applicationname.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true

[Install]
WantedBy=multi-user.target
16 changes: 16 additions & 0 deletions config/nameservice.socket
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#/etc/systemd/system/namesocket.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock
# Our service won't need permissions for the socket, since it
# inherits the file descriptor by socket activation
# only the nginx daemon will need access to the socket
SocketUser=www-data
# Optionally restrict the socket permissions even more.
# SocketMode=600

[Install]
WantedBy=sockets.target
42 changes: 33 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
#!/bin/sh

###############################
# Programa: install.sh
# Desenvolvido por: Vineees (@thevinisouza)
# Data de Criacao: 12/05/2024
# Versao: 1.0.0
###############################

python --version
sleep 2

echo "Antes de Iniciar a Instalação Verique se Já Configurou o .env!"
echo""
echo "Deseja Continuar?"
read -p "Press enter to continue"""

echo "Instalando Pacotes!"
sleep 2
sudo apt install nginx
sudo apt install cron

echo "Criando Enviroment"
sleep 2
# Create environment
python3 -m venv env
# Enter environment
. env/bin/activate

echo "Enviroment Criado!"
echo "Instalando dependencias!"

echo "Instalando dependencias!"
# Install Deps
python3 -m pip install -r ./requirements.txt

echo "Dependencias instaladas!"
echo "Configurando Database!"

echo "Configurando Database!"
python3 manage.py makemigrations
python3 manage.py migrate
echo "Database Configurada!"

echo "Database Configurado!"
echo "Copiando Estaticos"

cp ./media /var/www/html/Morea/
read -p “Informe o caminho completo para o diretorio dos estaticos (Ex:/var/www/html/morea/): “ STATICFOLDER
cp ./media $STATICFOLDER
python3 manage.py collectstatic --noinput

echo "Estaticos Copiados!"
echo "Estaticos Copiados!"

echo "Iniciando Configuração do Web Server"
read -p “Porta para hospedar o Serviço: “ NGINXPORT
read -p “Nome no qual o Nginx escutara o request (localhost, domain.net, 192.168.1.1, etc...): “ NGINXDOMAIN
sed -i 's/CHANGE-PORT/$NGINXPORT/' ./config/morea.conf
sed -i 's/CHANGE-DOMAIN/$NGINXDOMAIN/' ./config/morea.conf
sed -i 's/CHANGE-STATIC/$STATICFOLDER/' ./config/morea.conf
cp ./config/morea.conf /etc/nginx/sites-available
ln -s /etc/nginx/sites-available/morea.conf /etc/nginx/sites-enabled/
2 changes: 1 addition & 1 deletion morea_ds/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
ROOT_URLCONF = 'morea_ds.urls'

CRONJOBS = [
('0 0 * * *', 'app.graphs.generateAllMotes24hRaw')
('0 3 * * *', 'app.graphs.generateAllMotes24hRaw')
]

TEMPLATES = [
Expand Down

0 comments on commit c2577a0

Please sign in to comment.