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 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c