
Deploy Golang menggunakan Linux(Ubuntu)
16 June, 2024
0
0
0
Contributors
- Buat file `Systemd`
sudo nano /etc/systemd/system/myapp.service
- Isi konfigurasi
[Unit]
Description=My Go Application
After=network.target
[Service]
User=yourusername
Group=yourusergroup
ExecStart=/path/to/your/app/myapp
WorkingDirectory=/path/to/your/app
Restart=on-failure
RestartSec=3
[Install]
WantedBy=multi-user.target
- Reload
systemd
dan Enable Service
# Reload systemd manager configuration
sudo systemctl daemon-reload
# Enable the service to start on boot
sudo systemctl enable myapp.service
# Start the service now
sudo systemctl start myapp.service
- Check Status
sudo systemctl status myapp.service
- Layanan Log
sudo journalctl -u myapp.service -f
- Config nginx
server {
listen 80;
server_name chat.ximply.io;
location / {
proxy_pass http://127.0.0.1:3006;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}