Skip to content

juandiegoh/jaydiapps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend JayDiApps mobile apps

To run on container

docker build -t jdbackend .
docker run --publish 8001:8080 jdbackend

To run on EC2

sudo apt-get update
sudo apt-get install build-essential golang git
mkdir $HOME/go
export GOPATH=$HOME/go
go get github.com/juandiegoh/jaydiapps
cd ~/go/src/github.com/juandiegoh/jaydiapps
go build

Create upstart file

sudo vim /etc/init/jaydiapps.conf
description "start and stop the go program 'jaydiapps'"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

env USER='ubuntu'
env APP_DIR='/home/ubuntu/go/src/github.com/juandiegoh/jaydiapps/'
env APP_EXEC='jaydiapps'

exec start-stop-daemon --start --chuid ${USER} --chdir ${APP_DIR} --exec ${APP_DIR}${APP_EXEC} 

Logs

sudo start jaydiapps
sudo service jaydiapps stop
sudo tail -f /var/log/upstart/jaydiapps.log

Rotate logs

Create file /etc/logrotate.d/golang

/home/ubuntu/go/logs/*.log {
        daily
        missingok
        rotate 7
        compress
        notifempty
        nocreate
}

Redirect :80 to :8080

install nginx

sudo apt-get install nginx

Proxy :80 -> :8080

modify /etc/nginx/nginx.conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
	worker_connections 768;
	# multi_accept on;
}

http {
	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log debug;

	server {
                listen 80;
                # The host name to respond to
                server_name jaydiapps;

                location / {
                        proxy_pass http://localhost:8080/;
                        proxy_set_header X-Real-IP  $remote_addr;
                        proxy_set_header X-Forwarded-For $remote_addr;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-Port $server_port;
                        proxy_set_header X-Real-Scheme $scheme;
                }
        }
}

to start nginx

sudo nginx

to reaload when modified conf

sudo nginx -s reload

to stop nginx

sudo nginx -s stop

About

Backend for JayDiApps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages