dongyoulou4829 2014-10-31 07:15
浏览 51
已采纳

Upstart Yii控制台给了我错误

I am trying to run a backend process and I am hitting into problem getting the upstart to run the yiic command.

I am using xampp server

Here is my upstart script:

#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

So when i do

sudo start test-monitor

the upstart is starting and it it seems like it is firing a command to yii project as error is being caught in yii log file. The error in yii log file is:

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

However if I do the command manually:

./yiic project test

This are working fine. Can someone please help me.

Here is the codes for the yii console command:

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

Here is the log file of the upstart (It isn't the case as I have taken the sudo out):

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 connection is working fine and I have tested it

  • 写回答

1条回答 默认 最新

  • duanmangxie7131 2014-11-04 09:00
    关注

    After some persistent tries and some configuration, I managed to solve the issue.

    Since the server was a xampp server, php is installed in xampp thus there is an environment issue. Thus the bin directory of the php has to be referenced in the upstart as such:

    This was the solve on the upstart script:

    script
      exec /opt/lampp/bin/php -f /opt/lampp/htdocs/my_project/protected/yiic.php project test
    end script
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。