-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservico_windows.py
More file actions
46 lines (38 loc) · 1.46 KB
/
Copy pathservico_windows.py
File metadata and controls
46 lines (38 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
"""
Facilita RE Assinaturas - Script de Serviço Windows
Este script é usado pelo NSSM para executar o servidor Django.
Usa Waitress (servidor WSGI para produção em Windows) para melhor estabilidade.
"""
import os
import sys
# Define o diretório base do projeto
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
os.chdir(BASE_DIR)
# Adiciona o diretório ao path
sys.path.insert(0, BASE_DIR)
# Define variáveis de ambiente Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'facilita_re.settings')
if __name__ == '__main__':
# Tenta usar Waitress (recomendado para Windows)
try:
from waitress import serve
from facilita_re.wsgi import application
print("=" * 50)
print("Facilita RE Assinaturas - Servidor de Produção")
print("Iniciando com Waitress na porta 8001...")
print("=" * 50)
serve(
application,
host='0.0.0.0',
port=8001,
threads=4,
url_scheme='http',
ident='Facilita RE Assinaturas'
)
except ImportError:
# Fallback para o servidor de desenvolvimento
print("AVISO: Waitress não instalado. Usando servidor de desenvolvimento.")
print("Para produção, instale: pip install waitress")
from django.core.management import execute_from_command_line
execute_from_command_line(['manage.py', 'runserver', '0.0.0.0:8001', '--noreload'])