gpt4 book ai didi

php - Upstart 的 Yii 控制台给我错误

转载 作者:太空宇宙 更新时间:2023-11-04 03:49:56 25 4
gpt4 key购买 nike

我正在尝试运行后端进程,但在让 Upstart 运行 yiic 命令时遇到了问题。

我正在使用xampp服务器

这是我的 Upstart 脚本:

#description     "Sample upstart"

#start on stopped
start on startup
stop on shutdown
respawn

chdir /opt/lampp/htdocs/my_project/protected
setuid mad
setgid www-data

script
exec /opt/lampp/htdocs/my_project/protected/yiic project test
end script

所以当我这样做

sudo start test-monitor

Upstart 正在启动,它似乎正在向 yii 项目发出命令,因为 yii 日志文件中捕获了错误。 yii 日志文件中的错误是:

2014/10/31 15:06:44 [error] [worker.*] CDbConnection failed to open the DB connection: could not find driver
2014/10/31 15:06:44 [error] [worker.*] CDbConnection failed to open the DB connection: could not find driver
2014/10/31 15:06:44 [error] [worker.*] CDbConnection failed to open the DB connection: could not find driver
2014/10/31 15:06:44 [error] [worker.*] CDbConnection failed to open the DB connection: could not find driver

但是如果我手动执行命令:

./yiic project test

这工作正常。有人可以帮我吗?

这里是 yii 控制台命令的代码:

public function actionTest(){
try{
while(1){
TestManager::_MonitorTest();
usleep(1000000);
}
}catch(Exception $e){
Yii::log( $e->getMessage(), 'error', 'worker.*');
}
}

这是 Upstart 的日志文件(事实并非如此,因为我已经把 sudo 去掉了):

sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified
sudo: no tty present and no askpass program specified

Mysql连接工作正常,我已经测试过

最佳答案

经过一番不懈的尝试和一些配置,我成功解决了这个问题。

由于服务器是xampp服务器,php安装在xampp中,因此存在环境问题。因此,php 的 bin 目录必须在 upstart 中引用,如下所示:

这是 Upstart 脚本的解决方案:

script
exec /opt/lampp/bin/php -f /opt/lampp/htdocs/my_project/protected/yiic.php project test
end script

关于php - Upstart 的 Yii 控制台给我错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26669319/

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