Upstart Yii控制台给了我错误

时间:2014-10-31 07:15:36

标签: php linux yii upstart

我正在尝试运行后端进程,并且遇到了让upstart运行yiic命令的问题。

我正在使用xampp服务器

这是我的新贵脚本:

#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项目测试

这很好用。有人可以帮助我。

以下是yii控制台命令的代码:

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

这是暴发户的日志文件(因为我把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连接工作正常,我测试了它

1 个答案:

答案 0 :(得分:0)

经过一些持续尝试和一些配置后,我设法解决了这个问题。

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

这是upstart脚本的解决方法:

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