-
Notifications
You must be signed in to change notification settings - Fork 1
systemd
If you have been following the guides so far, at this point, you should be able to run Isabelle. At this point, we only have source files. Make sure to be in the /home/[username]/go/src/github.com/yiping-allison/isabelle
directory and run: go build -o isabelle.exe
The command above will compile all the source files and generate an executable called isabelle.exe
.
To run the executable, run: ./isabelle.exe
.
Bots by itself stop running after you close your ssh
session. In order to circumvent this, you must create a systemd
file.
To put simply, it is a service and system manager that runs on many linux distributions. We will be using systemd to start, stop, and restart Isabelle in case she goes offline.
Your systemd
file should be created in the /etc/systemd/system/
directory. If you just logged in using ssh user@server-ip-address
, you should be brought into your main home directory.
For example, using pwd
will show something like: /home/username/
.
If you see the above path, run cd ../..
This command will bring you to two directories above your current directory where all your system files are located.
If you use ls
, you should be able to see a etc folder inside. If you do, run cd /etc/systemd/system/
. This is where you should place your systemd file.
You can directly make the file from terminal by running sudo vi isabelle.service
.
Whenever you change a service file, you need to run systemctl daemon-reload
in order to reload your service settings.
[Unit]
Description=isabelle
After=network.target
[Service]
WorkingDirectory=/home/[username]/go/src/github.com/yiping-allison/isabelle
StandardOutput=inherit
StandardInput=inherit
Restart=always
RestartSec=0
ExecStart=/home/[username]/go/src/github.com/yiping-allison/isabelle/isabelle.exe
[Install]
WantedBy=multi-user.target
In the configuration file above, I set the working directory to /home/[username]/go/src/github.com/yiping-allison/isabelle
because it contains my executable and configuration file.
Restart=always tells the system to reboot the service whenever it goes offline. This will prevent our bot from going offline when we disconnect from ssh
.
ExecStart should contain the path to your executable file.
Assuming you named your service file isabelle.service...
To start your service, use: sudo systemctl start isabelle.service
.
Likewise to stop the service, use: sudo systemctl stop isabelle.service
.