rssnyder / discord-stock-ticker

Add live stock & crypto prices to your discord sidebar.
https://rssnyder.github.io/discord-stock-ticker/
MIT License
293 stars 113 forks source link

Save ticker on db #137

Closed ssamachi closed 2 years ago

ssamachi commented 2 years ago

I'm currently still learning linux so I'm not that familiar yet. I wanted to ask how will i add the -db setting so that I can save the tickers that I created.

I use this btw and I'm using a vps

wget https://github.com/rssnyder/discord-stock-ticker/releases/download/v3.3.0/discord-stock-ticker-v3.3.0-linux-amd64.tar.gz

tar zxf discord-stock-ticker-v3.3.0-linux-amd64.tar.gz

mkdir -p /etc/discord-stock-ticker

mv discord-stock-ticker /etc/discord-stock-ticker/

wget https://raw.githubusercontent.com/rssnyder/discord-stock-ticker/master/discord-stock-ticker.service

mv discord-stock-ticker.service /etc/systemd/system/

systemctl daemon-reload

systemctl start discord-stock-ticker.service
rssnyder commented 2 years ago

Edit the service file so it has the flags you need.

/etc/systemd/system/discord-stock-ticker.service

ssamachi commented 2 years ago

IMG_20220127_214549 Like this?

rssnyder commented 2 years ago

yes but, the path for your db looks wrong, just make it -db=./discordbottickers.db

ssamachi commented 2 years ago

Thanks. Do I have to stop the bot and make the tickers again or will this save the tickers that I have already?

rssnyder commented 2 years ago

Thanks. Do I have to stop the bot and make the tickers again or will this save the tickers that I have already?

be sure and do systemctl daemon-reload after every change to the systemd file, otherwise the changes wont take affect.

once the service has been started with the -db flag, any bots added will be stored in the DB. If you have bots running now added before you added the flag, they will need to be created again after restarting the service with the flag.

you can verify the DB is being using if you see this log line when you start the service INFO[0000] Will be storing state in ./discordbottickers.db

you can see logs with journalctl -f -u discord-stock-ticker

ssamachi commented 2 years ago

Thank you very much for this

rssnyder commented 2 years ago

Thank you very much for this

Anytime! I think the best way to make documentation is just to write stuff down when you teach someone new. https://github.com/rssnyder/discord-stock-ticker/commit/9740d88810dd8e1d5d48c1185627439a3e482192

ssamachi commented 2 years ago

Thank you very much for this

Anytime! I think the best way to make documentation is just to write stuff down when you teach someone new. 9740d88

IMG_20220128_093525

Is this correct?

rssnyder commented 2 years ago

you must have an error in your systemd file, share it here and ill take a look.

ssamachi commented 2 years ago

you must have an error in your systemd file, share it here and ill take a look.

IMG_20220128_100845 Here

I use systemctl edit discord-stock-ticker.service To edit

rssnyder commented 2 years ago

that isnt my template, what you should have is:

https://github.com/rssnyder/discord-stock-ticker/blob/master/discord-stock-ticker.service

[Unit]
Description=discord-stock-ticker
Wants=basic.target
After=basic.target network.target
Before=sshd.service

[Service]
SyslogIdentifier=discord-stock-ticker
StandardOutput=syslog
StandardError=syslog
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/etc/discord-stock-ticker/discord-stock-ticker -db=./discordbottickers.db
Restart=always

[Install]
WantedBy=multi-user.target
ssamachi commented 2 years ago

Will the db file create itself or do I have to make one first?

rssnyder commented 2 years ago

Will the db file create itself or do I have to make one first?

do not create it first it will create the file itself.

ssamachi commented 2 years ago

IMG_20220128_104318 I got another error

IMG_20220128_104332 I just copied and pasted the one you sent.