Static IP + systemd: Go Live & Stay Up

Harry · 14 Sep 2026 · 1 views
Advertisement
Advertisement

Reserve a static public IP

An ephemeral IP can change after a stop/start — fine for testing, bad for a production URL. Reserve it once and attach it to the instance:

oci network public-ip create \
  --compartment-id $COMP_OCID \
  --lifetime RESERVED
# then in the console, attach that Reserved Public IP to your instance NIC.
# Your URL now survives reboots forever.

Daemonize the Spring app with systemd

sudo mkdir -p /opt/groovygrails
sudo cp /tmp/demo-0.0.1-SNAPSHOT.war /opt/groovygrails/app.war
sudo tee /etc/systemd/system/groovygrails.service > /dev/null <<'EOF'
[Unit]
Description=GroovyGrails Spring Boot App
After=network.target

[Service]
User=tomcat
WorkingDirectory=/opt/groovygrails
ExecStart=/usr/bin/java -jar /opt/groovygrails/app.war
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now groovygrails

Check it really stays up

systemctl status groovygrails
sudo journalctl -u groovygrails -f
# after a reboot it should come back by itself:
sudo reboot

The Restart=always + enabled combo means the app comes back after crashes and reboots with zero manual steps — the whole point of a reliable always-free VPS.

Share this post:

Comments (0)

Please login or register to comment.