-
-
Notifications
You must be signed in to change notification settings - Fork 759
systemd configuration
The systemd-version used for this setup is 219, we'll be using a venv for python and nano for text-operations, the sample user is called ec2-user and the bot is cloned to /home/ec2-user/bot.
Paste code in nano = mouse-rightclick
SAVE file in nano = CTRL + O followed by ENTER
EXIT file in nano = CTRL + X
Create the service config file via opening the texteditor 'nano'
sudo nano /lib/systemd/system/binancebot.servicePaste the following code into the file, edit paths and user in WorkingDirectory, User and ExecStart to suite your settings, SAVE and EXIT
[Unit]
Description=Binance Bot Service
After=multi-user.target
[Service]
Type=idle
WorkingDirectory=/home/ec2-user/bot
User=ec2-user
ExecStart=/home/ec2-user/bot/.venv/bin/python3 -u '/home/ec2-user/bot/Binance Detect Moonings.py'
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=binance-bot
[Install]
WantedBy=multi-user.targetCreate the rsyslog configuration via opening the texteditor 'nano'
sudo nano /etc/rsyslog.d/binancebot.confPaste the following code into the file (rightclick), SAVE and EXIT
template(name="bot-tmplt" type="string"
string="%msg:1:$%\n"
)
if $programname == "binance-bot" then /var/log/binancebot/bot.log;bot-tmplt
& stopCreate the logfile folder
sudo mkdir /var/log/binancebotJust to be on the safe side: Create the logfile in the folder, SAVE and EXIT
sudo nano /var/log/binancebot/bot.logRefresh services list
sudo systemctl daemon-reloadRestart rsyslog service (i think this could be skipped as we are rebooting soon)
sudo systemctl restart rsyslogEnable the Binance Bot service to run at system boot
sudo systemctl enable binancebotReboot the machine
sudo rebootNow we have setup the bot as a service and it autostarts with the machine.
We can manually start, stop, restart and view the status of the service with the following commands:
sudo systemctl start binancebotsudo systemctl stop binancebotsudo systemctl restart binancebotsudo systemctl status binancebotTo view the log file we can use e.g. tail or mutlitail (if installed)
tail -f -n 100 /var/log/binancebot/bot.logAny changes to the config files of either of the services will need to be applied with at least:
sudo systemctl daemon-reload
sudo systemctl restart SERVICENAMEChanging the config.yml of the bot requires sudo systemctl restart binancebot to be applied.