~reesmichael1/chantpointer

1423d58384a3cf9bbdd0e0b05dd0ef70fed84cc8 — Michael Rees 3 years ago 849b27f
Migrate to different server
2 files changed, 14 insertions(+), 8 deletions(-)

M .build.yml
M main.go
M .build.yml => .build.yml +7 -7
@@ 5,9 5,10 @@ packages:
sources:
    - https://git.sr.ht/~reesmichael1/chantpointer
environment:
    deploy: chantpointer@104.248.101.90
    deploy: chantpointer@142.93.10.195
secrets:
    - d7ae6197-e2bd-42be-b9b1-5141cf17c01c
    - 5c21e93c-6d8e-410a-9ae4-35dcc51acd8c
    - fadfa027-e02e-46d2-bf1a-3547dfe92ccc
tasks:
    - test: |
        cd chantpointer


@@ 17,8 18,7 @@ tasks:
        go build -o bin/server
    - deploy: |
        cd chantpointer
        sshopts="ssh -o StrictHostKeyChecking=no"
        rsync --rsh="$sshopts" -r bin $deploy:/home/chantpointer/deploy
        rsync --rsh="$sshopts" -r static $deploy:/home/chantpointer/deploy
        rsync --rsh="$sshopts" -r templates $deploy:/home/chantpointer/deploy
        ssh $deploy "sudo systemctl restart server"
        rsync -r bin $deploy:/home/chantpointer/deploy
        rsync -r static $deploy:/home/chantpointer/deploy
        rsync -r templates $deploy:/home/chantpointer/deploy
        ssh $deploy "sudo systemctl restart chantpointer"

M main.go => main.go +7 -1
@@ 1,15 1,21 @@
package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
)

func main() {
	var port int
	flag.IntVar(&port, "port", 7777, "the port that the server will run on")
	flag.Parse()

	static := http.FileServer(http.Dir("static"))
	http.Handle("/static/", http.StripPrefix("/static", static))
	http.HandleFunc("/chant/", ChantHandler)
	http.Handle("/generate", ErrorHandler(GenerateHandler))
	http.Handle("/", ErrorHandler(IndexHandler))
	log.Fatal(http.ListenAndServe(":8080", nil))
	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
}