Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • ThomasPowell 8:59 pm on August 18, 2020 Permalink
    Tags: ec2, minecraft   

    Deploying a Minecraft Server to EC2 (with some cost analysis) 

    Caveat… an EC2 server is likely not the option you want to pursue for a small to medium scale Minecraft server… Lightsail will be more cost-effective due to the amount of data transfer involved. Also, this is partly an exercise it navigating Amazon Linux as a largely Ubuntu user. If you really want to host your own Minecraft server on a virtual server, I’ve also done this exercise minus 90% of the steps on a 2GB Linode (get a $100, 60-day credit through that referral link) and you will not get a huge egress bill for the insane amount of data you transfer out. OR if you want a fairly plug-and-play solution, PebbleHost offers Minecraft hosting for as little as $1/month ($3-5 basic plan recommended depending on your needs)

    Purchase a Domain

    I’m going through Namecheap for a .online domain because… well… it’s cheap… and registering revrestfarcenim.online (.online domain through Route 53 would be $39 vs. $1.88 for the first year with Namecheap).

    Launch an EC2 instance

    If you’re trying to use free-tier resources for this, you’ll want to go for a t2.micro, but you’ll also need to modify the java parameters for the server to fit within those memory limits.

    • Go to the EC2 console via Services -> EC2
    • Scroll down in the main window to “Launch instance” and click [Launch Instance]
    • Select Amazon Linux 2 AMI (should be the first option)
    • I’m selecting t3a.small ec2 instancetype for this to be similar in “virtual” resources as the $10-15/mo virtual server hosting providers (including Amazon Lightsail).
    • Click [Next: Configure Instance Details]
    • You’ll get a default vpc and subnet created and selected… if you don’t want to use these, you can click the available links to create new ones.
    • For “Auto-assign Public IP”, I have “Use subnet setting (Enable)” because I’m going to want to have this publicly accessible.
    • Scroll to near the bottom of the “Step 3” form and find “T2/T3 Unlimited” and uncheck “Enable” unless you want to run up a bill because you forgot about the Minecraft server.
    • Click [Next: Add Storage] to configure your space.
    • Click [Next: Add Tags]
    • Click [Next: Configure Security Group]
    • Click [Add Rule] and add a Custom TCP Rule that allows traffic to port 25565 (the port for Minecraft) from 0.0.0.0/0
    • Click [Review and Launch]
    • Click [Launch] and choose “Create a new key pair” named “minecraftserver”
    • Click on Instances and select your new instance, noting the IPv4 Public IP in the instance details below (leave tab open for reference in the next section)

    Create a Hosted Zone in Route 53

    • In a new tab, go to Services -> Route 53 -> Hosted Zones
    • Click [Create hosted zone]
    • Type in your domain name for your server and select “Public hosted zone”
    • Copy the values for the NS record and populate those as the nameservers for your domain (for me, this is on Namecheap
    Route 53 NS record
    Namecheap Custom DNS settings
    • Now go back to Route 53 and [Create Record]
    • Choose “Simple routing”
    • Click [Define simple record]
    • Leave the record name blank.
    • Under “Value/Route traffic to” select “IP address or another value depending on the record type” and paste your IP in.
    • Be sure “Record type” is “A” and click [Define simple record]
    Routing your A (alias) record in Route 53 to your EC2 instance
    • Click [Create records] on the “Configure records” screen.

    Install and setup Minecraft

    • Using your keypair from instance creation, ssh into your your instance
    chmod 400 minecraftserver.pem # or whatever the filename is
    ssh -i minecraftserver.pem ec2-user@revrestfarcenim.online
    
    • Create minecraft server folder and user
    sudo mkdir /srv/minecraft-server # assuming EBS mount
    sudo adduser --system --home /srv/minecraft-server minecraft
    sudo chown minecraft.minecraft /srv/minecraft-service
    
    • Do updates and install java
    sudo yum update
    sudo amazon-linux-extras install java-openjdk11
    
    • Download minecraft server, run for the first time, and set the eula.txt
    sudo -u minecraft wget https://launcher.mojang.com/v1/objects/a412fd69db1f81db3f511c1463fd304675244077/server.jar
    sudo -u minecraft java -Xmx1024M -Xms1024M -jar server.jar nogui
    # you'll get an error, so edit the eula.txt
    sudo -u minecraft nano eula.txt # or vi, just set to eula=true
    # run minecraft again and try to connect to server at revrestfarcenim.online
    

    Making Minecraft a service

    • Run sudo nano /lib/systemd/minecraft-server.service
    • Paste a config similar to:
    [Unit] 
    Description=start and stop the minecraft-server 
    
    [Service]
    WorkingDirectory=/srv/minecraft-server
    User=minecraft
    Group=minecraft
    Restart=on-failure
    RestartSec=20 5
    ExecStart=/usr/bin/java -Xms1024M -Xmx1024M -jar server.jar nogui
    
    [Install]
    WantedBy=multi-user.target
    
    • Now, enable the service with sudo systemctl enable /lib/systemd/minecraft-server.service
    • And start the service with sudo systemctl start minecraft-server.service
    • As it’s starting, you can check the status with sudo systemctl status minecraft-server.service.
    • With this systemctl setup, you should also be able to reboot the instance and have the Minecraft server come back up

    Troubleshooting

    • If you don’t go with the default gateway and subnets created with the instance, you may find yourself having to explicitly set up an Internet Gateway and a Route Table (0.0.0.0/0 to your igw)
    • Make sure the associated security group is allowing port 25565 to connect (especially if SSH is working)

    Teardown

    Be sure to delete your hosted zone (you’ll need to delete the A record before deleting the zone) and terminate your instance to avoid running up charges for things you’re not using. I deleted the VPC as well just to avoid clutter and half-baked subnets and security groups, but that’s only because I have nothing of long-term value in the account.

    Cost Analysis

    There are multiple hits that you’re going to take by hosting this on EC2:

    • egress costs (9¢ per GB after your first GB): In my limited tests, the Minecraft worlds we started up required 100-200MB to initially download per session. It’s unclear if that’s the case for every session, but if you have 20 of your friends use a server, that might be 9¢ x 0.20 GB x 20 for one session each… 36¢ per average number of sessions… that could add up quickly. By contrast, you could get a different hosting provider (including Lightsail) to bundle 2TB of transfer instead.
    • hosted zone cost (50¢ for a distinct domain’s hosted zone)
    • If you use a separate EBS volume, minimum cost there is 80¢.
    • EC2 pricing for a t3a.small is 1.88¢ per hour or $13.53/month… you could have the server shut down during off-hours, but then you’re not comparing to “always-on” options.
     
  • ThomasPowell 7:35 am on September 23, 2022 Permalink | Reply
    Tags: , meetings   

    20 Meeting Personalities 

    This list was put together from experiences with experiences with conference calls in 2011. It’s interesting to see, depending on my role on a team or in an organization, how many of the “personalities” below I’ve adopted. It’s also interesting to see how the “all remote” meetings post-pandemic have made some of “personalities” or commentary obsolete.

    • Off-mute chewer – Chews on (lunch?) audibly into the microphone.
    • Absent-minded mute button user – Starts responding with the mute button on for about a minute or more before realizing that no one is hearing the response.
    • Mute button blamer – Wasn’t paying attention. 
      Had to have name called several times.
      Blames mute button for not having a clue what’s going on.
      See also: How the Mute Button on Your Phone Actually Works
    • Clock Watcher – Spends more time checking watch that actually participating in meeting.
    • Filibusterer – Single handedly talks the meeting into oblivion. (Not to be confused with the derailer or rambler.)
    • Derailer – Somehow manages to bring up tangential topics that get everyone completely off topic for the next 15 minutes.
    • Rambler – Responds to any question with a barely intelligible introspection on the topic.
      Responds to follow-up questions for clarification grow at an exponential rate.
    • Hedger – Treats every remote possibility as likely and stays non-committal unless you accept the exceptions noted.
    • Side Conversation Starter – Either completely oblivious or too rude to care that another meeting is going on.
    • Overhead speaker – Not an actual attendee or person, but an object which causes an echo in speakerphones and disrupts the meeting until it becomes silent again.
    • Tattle-tale – At the first of not getting his or her way, threatens to go tell a more powerful person to whom the tattler is connected.
    • Foot-propper – The meeting is a lounge to this person:  Feet are propped up on the table and behaves generally too relaxed to actually be engaged in the meeting.
    • Multitasker – Furiously typing on the keyboard, but obviously not to take notes on the meeting. (Don’t bother asking this person questions unless you want to rehash the entire meeting.)
    • Referee – “Sees the merits of both sides” of an intense debate.
      Tries to make everybody play nice, regardless of their agendas.
    • Idea killer – Always has a negative scenario for any proposal.
      Never has an idea himself.
    • Yes man – Would say no pants Friday at the office was a good idea, provided the right person proposed it.
    • Interrupter – Jumps in mid-details and often freaks out about half the story or asks questions whose answers were already on their way.
    • Belittler – Often pulls rank or “experience” to shut other people off.
    • Saboteur – Is either annoyed at the assignment or annoyed at not getting the project lead, but plays nice during the meeting, silently plotting the slow death of the project. (Can also accomplish goals as an inciter.)
    • Inciter – May jump communication chains to create the illusion of one person hiding information from another.
     
  • ThomasPowell 1:56 pm on September 17, 2022 Permalink | Reply
    Tags: , imessage   

    Annoy your friends with iMessage and AppleScript 

    Ever want to send a text message but you don’t have the energy to send it one word at a time? If you have macOS signed into iMessage, you can use AppleScript to automate sending one word at a time! (Warning: Doing this more than a few times will probably get you blocked by the people you know!)

    (The below script is available at send_message.applescript)

    #!/usr/bin/env osascript
    
    #  CREDIT TO https://chrispennington.blog/blog/send-imessage-with-applescript/ for how to send iMessages via AppleScript
    
    on run parameters
      # the number here is the number of seconds
      set theDelay to 3
    
      # Change this to the phone number of the iMessage contact to use
    
      set phoneNumber to "+1 (555) 555-1212"
      tell application "Messages"
        set targetBuddy to phoneNumber
        set targetService to id of 1st account whose service type = iMessage
        repeat with arg from 1 to length of parameters
          set textMessage to ( item arg of parameters )
          set theBuddy to participant targetBuddy of account id targetService
          send textMessage to theBuddy
          delay theDelay
        end repeat
      end tell
      log "Message sent"
    end run
    

    The repeat with arg from 1 to length of parameters and end repeat is essentially AppleScript’s for loop, with arg being the loop variable and 1 to length of parameters being the closed range on 1 to the end of the parameters list. Changing the value of theDelay can separate the messages by different number of seconds (currently 3 seconds)

    You need to chmod +x the script and update the phone number and then you can run it like:

    ./send_message.applescript This is a message to send

    Results of running AppleScript

This is a [Read 1:49PM] message to send with one blue bubble on each line
    Results of sending iMessages via AppleScript to myself

    You can group words with quotes as well

    ./send_message.applescript "This is a" "message to send"

    AppleScript with quoted arguments.

"This is a" "message to send"

    Remember: Use / abuse of this script may get you blocked. This script is purely for educational purposes.

     
  • ThomasPowell 6:29 pm on September 9, 2022 Permalink | Reply
    Tags: , vim-plug,   

    Windows vim-plug error 

    When trying to port my macOS .vimrc to Windows and attempting to set up vim-plug, I ran into the following error

    Windows vim-plug error

The system cannot find the path specified.
Error detected while processing function <SNR>2_install[1]..<SNR>2_update_impl[62]..<SNR>2_git_version_requirement[2]..<SNR>2_system[30]..function <SNR>2_install[1]..<SNR>2_update_impl[62]..<SNR>2_git_version_requirement[2]..<SNR>2_system:
line   24:
E282: Cannot read from "C:/Users/twill/AppData/Local/Temp/VF3575F.tmp"
Press ENTER or type command to continue

    In searching, I found this issue on vim-plug’s GitHub repo: Error when I try to install plugins on Windows. The comment on setting shellslash made me look in my own .vimrc:

    set shell=/bin/bash

    Commenting that out with the following resolved the issue. (No admin

    " set shell=/bin/bash

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: