Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu下运行成功 #19

Closed
sileence114 opened this issue Jan 3, 2023 · 2 comments
Closed

Ubuntu下运行成功 #19

sileence114 opened this issue Jan 3, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@sileence114
Copy link

sileence114 commented Jan 3, 2023

前提:已安装screen curl python3等,已在腾讯云Ubuntu 22.04 LTS上成功运行。

安装nodejs

安装apt install的node在安装依赖时会出问题,需要通过

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

安装nodejs。

安装依赖

  1. 安装python依赖(略)。
  2. 依次进入MiguMusicApiQQMusicApiNeteaseCloudMusicApi,使用npm install安装node依赖。

安装ffmpeg

只要确保能在工作目录下使用ffmpeg即可。
如使用apt安装

sudo apt install ffmpeg

启动脚本

仓库提供的run.sh并不能一次全部将所需api启动,需要将前一个进程结束才会启动下一个。这里使用screen魔改了一下。

#!/usr/bin/env bash
echo "========================"
echo "-start    Strat the bot."
echo "-stop     Stop the bot."
echo "========================"
echo ""

function start(){
	screen -dmS KO-ON-scheduler python3 scheduler.py
	echo "Start KO-ON-scheduler."

	cd MiguMusicApi
	screen -dmS KO-ON-MiguMusicApi npm start
	cd ../
	echo "Start KO-ON-MiguMusicApi."

	cd QQMusicApi
	screen -dmS KO-ON-QQMusicApi npm start
	cd ../
	echo "Strat KO-ON-QQMusicApi."

	cd NeteaseCloudMusicApi
	screen -dmS KO-ON-NeteaseCloudMusicApi node app.js
	cd ../
	echo "Start KO-ON-NeteaseCloudMusicApi."

	screen -dmS KO-ON-core python3 core.py 1
	echo "Start KO-ON-core."

}
function stop(){
	screen -S KO-ON-scheduler -X quit
	echo "Stop KO-ON-scheduler."

	screen -S KO-ON-MiguMusicApi -X quit
	echo "Stop KO-ON-MiguMusicApi."

	screen -S KO-ON-QQMusicApi -X quit
	echo "Stop KO-ON-QQMusicApi."

	screen -S KO-ON-NeteaseCloudMusicApi -X quit
	echo "Stop KO-ON-NeteiaseCloudMusicApi."

	screen -S KO-ON-core -X quit
	echo "Stop KO-ON-core."
}

running=0
if (( $(screen -ls | grep -c -P '^\t\d+\.KO-ON-(core|NeteaseCloudMusicApi|QQMusicApi|MiguMusicApi|scheduler)\t') > 0 )); then
	# screen names KO-ON is running.
	running=1
fi

if [[ $1 == "-start" ]]; then
	if [ $running == 1 ]; then
		echo "KO-ON is running. Stop it then restarting."
		stop
		start
		echo "Done."
	else
		start
		echo "Done."
	fi
elif [[ $1 == "-stop" ]]; then
	if [ $running == 1 ]; then
		stop
		echo "Done."
	else
		echo "KO-ON didn't run."
	fi
else
	echo "Toggle KO-ON run/stop"
	if [ $running == 1 ]; then
		stop
	else
		start
	fi
fi

The End

不出意外的话,运行./run.sh后就会出现五个screen。

@ddxgtx
Copy link

ddxgtx commented Jan 6, 2023

成功部署

@Gunale0926 Gunale0926 added the documentation Improvements or additions to documentation label Jan 10, 2023
@Gunale0926 Gunale0926 pinned this issue Jan 10, 2023
@kkc141
Copy link

kkc141 commented Oct 19, 2024

成功部署
zmq問題請看這個 https://github.com/KkemChen/KO-ON-BOT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants