gpt4 book ai didi

linux - MySQL 启动后在启动时运行脚本

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:41:48 24 4
gpt4 key购买 nike

我想在我的 Raspberry Pi 启动时启动 Seafile(需要 MySQL 的云服务器)。我的问题是,Seafile 在 mysql 之前启动并导致许多错误,因为 seafile 需要 mysql。我拿了推荐的剧本:

#! /bin/sh
# /etc/init.d/seafile

### BEGIN INIT INFO
# Provides: seafile
# Required-Start: $local_fs $remote_fs $network mysql
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Script to start/stop/restart seafile
# Description: Simple script to start, stop or restart seafile for the cloud
### END INIT INFO

# Change the value of "user" to your linux user name
user=chromo

# Change the value of "script_path" to your path of seafile installation
seafile_dir=/home/chromo/cloud
script_path=${seafile_dir}/seafile-server-latest
seafile_init_log=${seafile_dir}/logs/seafile.init.log
seahub_init_log=${seafile_dir}/logs/seahub.init.log

# Change the value of fastcgi to true if fastcgi is to be used
fastcgi=true
# Set the port of fastcgi, default is 8000. Change it if you need different.
fastcgi_port=8000

case "$1" in
start)
sudo -u ${user} ${script_path}/seafile.sh start >> ${seafile_init_log}
if [ $fastcgi = true ];
then
sudo -u ${user} ${script_path}/seahub.sh start-fastcgi ${fastcgi_port} >> ${seahub_init_log}
else
sudo -u ${user} ${script_path}/seahub.sh start >> ${seahub_init_log}
fi
;;
restart)
sudo -u ${user} ${script_path}/seafile.sh restart >> ${seafile_init_log}
if [ $fastcgi = true ];
then
sudo -u ${user} ${script_path}/seahub.sh restart-fastcgi ${fastcgi_port} >> ${seahub_init_log}
else
sudo -u ${user} ${script_path}/seahub.sh restart >> ${seahub_init_log}
fi
;;
stop)
sudo -u ${user} ${script_path}/seafile.sh $1 >> ${seafile_init_log}
sudo -u ${user} ${script_path}/seahub.sh $1 >> ${seahub_init_log}
;;
*)
echo "Usage: /etc/init.d/seafile {start|stop|restart}"
exit 1
;;
esac

有人可以帮助我吗?

最佳答案

最好的办法是在 /etc/rc[runlevel].d 文件中设置启动这些服务的优先级。

在您的情况下,首先要检查的是您启动到的运行级别。您可以使用命令“runlevel”进行检查。你也可以检查

比如说,你已经启动到运行级别 3。你可以重命名目录“/etc/rc3.d”中的当前 seafile 文件。

例如:

如果两个文件是

/etc/rc3.d/20seafile
/etc/rc3.d/50mysql

将文件重命名为 70seafile 或任何高于 50 的名称。

这应该可以解决您现在面临的问题。

另一种解决方法是删除到/etc/init.d 目录的 seafile 链接并放置一行内容

/etc/init.d/seafile start 

在文件 /etc/rc.local

请检查它并让我知道它是否为您解决了问题。

关于linux - MySQL 启动后在启动时运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27879468/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com