- Install dependencies with
yarn install
. - Compile ts to js with
yarn tsc
. - Create the
.env
file as below.TELEGRAM_BOT_SECRET=<bot-secret> QIS_USERNAME=<username> QIS_PASSWORD=<password> PRIVATE_USER_ID=<user-id of user who gets the actuall grade and additional information like logging>
- Run the node application with
node --env-file=.env built/index.js
- Create
/lib/systemd/system/htwk-qis-grade-notification-bot.service
[Unit] Description=htwk-qis-grade-notification-bot Documentation=https://github.com/kmathmann/htwk-qis-grade-notification-bot After=network.target [Service] Type=simple User=<username> ExecStart=<path-to-node-executable> --env-file=.env built/index.js WorkingDirectory=<path-to-repository> Restart=on-failure [Install] WantedBy=multi-user.target
- Activate the service with
sudo systemctl enable htwk-qis-grade-notification-bot
- Start the service with
sudo systemctl start htwk-qis-grade-notification-bot
To access the logs execute journalctl -u htwk-qis-grade-notification-bot.service
In combination with fnm we need a script that initializes fnm before we can use node
.
Create the following run-htwk-qis-grade-notification-bot.sh
file and make it executeable with chmod +x run-htwk-qis-grade-notification-bot.sh
#!/bin/bash
export PATH="/home/<user>/.local/share/fnm:$PATH";
eval "`fnm env --shell bash`";
node --env-file=.env built/index.js;
In /lib/systemd/system/htwk-qis-grade-notification-bot.service
we change the ExecStart
line to:
ExecStart: <path-to-file>/run-htwk-qis-grade-notification-bot.sh
yarn tsc && node --env-file=.env built/index.js