If you haven’t installed tonutils-reverse-proxy
, follow the instructions docs.ton.org/develop/dapps/tutorials/how-to-run-ton-site, for example:
curl -fsSL -o tonutils-reverse-proxy https://github.com/ton-utils/reverse-proxy/releases/latest/download/tonutils-reverse-proxy-linux-amd64
chmod +x tonutils-reverse-proxy
mv tonutils-reverse-proxy /usr/local/bin/
Make sure the binary works:
tonutils-reverse-proxy --help
mkdir -p /etc/tonutils-reverse-proxy
To manage tonutils-reverse-proxy
, create a script at /etc/init.d/tonutils-reverse-proxy
:
nano /etc/init.d/tonutils-reverse-proxy
Insert the following code:
#!/bin/bash
# /etc/init.d/tonutils-reverse-proxy
# System V init script for tonutils-reverse-proxy
### BEGIN INIT INFO
# Provides: tonutils-reverse-proxy
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts tonutils-reverse-proxy
# Description: A reverse proxy for TON decentralized sites.
### END INIT INFO
NAME="tonutils-reverse-proxy"
BIN="/usr/local/bin/tonutils-reverse-proxy --domain your-domain.ton"
PIDFILE="/var/run/$NAME.pid"
LOGFILE="/var/log/$NAME.log"
start() {
echo "Starting $NAME..."
if [ -f $PIDFILE ]; then
echo "$NAME is already running."
else
cd /etc/tonutils-reverse-proxy || exit 1
nohup $BIN > $LOGFILE 2>&1 &
echo $! > $PIDFILE
echo "$NAME started."
fi
}
stop() {
echo "Stopping $NAME..."
if [ -f $PIDFILE ]; then
kill $(cat $PIDFILE) && rm -f $PIDFILE
echo "$NAME stopped."
else
echo "$NAME is not running."
fi
}
status() {
if [ -f $PIDFILE ]; then
echo "$NAME is running. PID: $(cat $PIDFILE)"
else
echo "$NAME is not running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit 0
Grant execute permissions to the script:
chmod +x /etc/init.d/tonutils-reverse-proxy
Add the service to startup:
update-rc.d tonutils-reverse-proxy defaults
You can now use the following commands:
Start:
service tonutils-reverse-proxy start
Stop:
service tonutils-reverse-proxy stop
Restart:
service tonutils-reverse-proxy restart
Check status:
service tonutils-reverse-proxy status
Logs will be saved to /var/log/tonutils-reverse-proxy.log
. You can view them using:
tail -f /var/log/tonutils-reverse-proxy.log
Now your tonutils-reverse-proxy
is set up as a service, and you can manage it via System V init.