AWS

신홍석·2023년 2월 23일
0

Go-Learning

목록 보기
1/1

Building EC2

  1. Build hello world
  • GOOS=linux GOARCH=amd64 go build -o
  1. Copy your binary to the server
  • scp -i /path/to/your.pem ./main ubuntu@ec2-user@[public-DNS]
  1. SSH into your server
    ex) ssh -i ./kp-2023-2-23.pem ubuntu@ec2-3-34-189-211.ap-northeast-2.compute.amazonaws.com

  2. ls -al

  3. sudo chmod 777 [your binary]
    700 only me

  4. ls -al (check your binary)

  5. sudo ./[your binary]

persisting your application

possible options

  • screen
  • init.d
  • upstart
  • system.d

start

  1. cd /etc/systemd/system

  2. sudo nano hello.service
    (place this code inside)
    [Unit]
    Description=Go Server

[Service]
ExecStart=/home/username/exepath
User=root
Group=root
Restart=always

[Install]
WantedBy=multi-user.target

  1. ctrl + o

  2. ctrl + x

  3. sudo systemctl enable hello.servie

  4. sudo systemctl start hello.service

  5. sudo systemctl status hello.service

profile
백엔드 개발자 공부

0개의 댓글