fex-team / fis

Front-end Integrated Solution - 前端集成解决方案, 最新版请进入 FIS3 https://github.com/fex-team/fis3
http://fis.baidu.com
MIT License
2.96k stars 655 forks source link

关于使用fis release -d部署到远程服务器的问题 #364

Open woshiwenzhijie opened 9 years ago

woshiwenzhijie commented 9 years ago

步骤:

  • 配置fis-confi.js代码如下
fis.config.merge({
    deploy: {
        remote: [
            {
                receiver: 'http://192.168.48.142:9999/receiver.php',
                from: 'index.html',
                to: '/sdp'
            }
        ]
    }
});
  • 服务器端启动apache,将receiver.php复制到目标目录下,浏览器访问serverIp:port/receiver.php打印出I'm ready for that, you know.至此,服务器端启动完成
  • 在目录下面执行fis release -d remote,发现文件没有成功post到服务器端,这里面的步骤我遗漏了什么吗?
woshiwenzhijie commented 9 years ago

@xiangshouding @fouber

woshiwenzhijie commented 9 years ago

有人吗? 急。。。

2betop commented 9 years ago

to 设置的 /sdp 这个文件夹存在吗?或者有写入权限吗?最好贴下错误信息

woshiwenzhijie commented 9 years ago

@2betop 没有错误信息。。 image

woshiwenzhijie commented 9 years ago

@2betop 你们的远程发布的操作步骤能说一下吗?

oxUnd commented 9 years ago

你把全部的配置文件发一下,我看看。另外可以在命令行加参数 --verbose 来查看具体编译流程。

2betop commented 9 years ago

就是将产出文件通过 http post (multipart 格式)发送给目标文件,即指定的 reciver.php 文件。接受文件负责将文件写入到服务器。返回0表示正常

woshiwenzhijie commented 9 years ago

fis-conf.js

fis.config.merge({
    deploy: {
        local: [
            {
                to: '../sdp_release'
            }
        ],
        remote: [
            {
                receiver: 'http://127.0.0.1/receiver.php',
                from: 'index.html',
                to: '/sdp'
            }
        ]
    }
});
woshiwenzhijie commented 9 years ago

配置完上面那个我就用xampp起了一个本地的apache服务,之前是有加端口号80,现在没加

然后就直接运行 fis release -d remote

woshiwenzhijie commented 9 years ago

将产出文件通过 http post (multipart 格式)发送给目标文件这个你是通过什么方式做的,不是通过fis的deploy里头配置remote的方式做吗? @2betop

2betop commented 9 years ago

remote 是接受地址,我说的是文件发送方式!

woshiwenzhijie commented 9 years ago

执行完fis release -d remote之后fis没有根据deploy的配置信息自动将指定文件发送到目标文件吗?

woshiwenzhijie commented 9 years ago

??? @2betop @xiangshouding

2betop commented 9 years ago

你把 from 删了,怀疑是 from 过滤掉了文件!

woshiwenzhijie commented 9 years ago

恩,确实是from 的问题,不过upload过程中报错了 C:\Users\Administrator\AppData\Roaming\npm\node_modules\fis\node_modules\fis-kernel\lib\log.js:63 throw err ^ Error: upload file [/img/now.gif] to [/sdp] by receiver [http://127.0.0.1:80/receiver.php] error [] at Object.exports.error (C:\Users\Administrator\AppData\Roaming\npm\node_modules\fis\node_modules\fis-kernel\lib\log.js:57:15) at C:\Users\Administrator\AppData\Roaming\npm\node_modules\fis\node_modules\fis-deploy-default\index.js:59:25 at IncomingMessage. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\fis\node_modules\fis-kernel\lib\util.js:835:21) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:944:16 at process._tickCallback (node.js:442:13)

2betop commented 9 years ago

这下就要找 php 的原因了。看下php那块的日志,怀疑是权限问题

woshiwenzhijie commented 9 years ago

php是用你们提供的这个

<?php
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
function mkdirs($path, $mod = 0777) {
    if (is_dir($path)) {
        return chmod($path, $mod);
    } else {
        $old = umask(0);
        if(mkdir($path, $mod, true) && is_dir($path)){
            umask($old);
            return true;
        } else {
            umask($old);
        }
    }
    return false;
}
if($_POST['to']){
    $to = urldecode($_POST['to']);
    if(is_dir($to) || $_FILES["file"]["error"] > 0){
        header("Status: 500 Internal Server Error");
    } else {
        if(file_exists($to)){
            unlink($to);
        } else {
            $dir = dirname($to);
            if(!file_exists($dir)){
                mkdirs($dir);
            }
        }
        echo move_uploaded_file($_FILES["file"]["tmp_name"], $to) ? 0 : 1;
    }
} else {
    echo 'I\'m ready for that, you know.';
}
woshiwenzhijie commented 9 years ago

中间有报错,但是部分文件有上传成功,应该不是权限问题吧,如果是的话一个都无法写入吧

woshiwenzhijie commented 9 years ago

看报错的信息是[/img/now.gif],然后我把这个文件删除了,就可以了。。。。 - - !!!! 阿西吧,这是什么原因。。

woshiwenzhijie commented 9 years ago

找了一下午,没找到原因 - - !!! 现在的处理方法是先把出错的图片手动扔上去了。。。

2betop commented 9 years ago

突然想到,是不是文件大小超了?

woshiwenzhijie commented 9 years ago

是的!!!!!!!!!!!!!!

woshiwenzhijie commented 9 years ago

btw,有相应的java代码吗?

woshiwenzhijie commented 9 years ago

@2betop @xiangshouding 需要java配置文件,甩一个可否?

2betop commented 9 years ago

java version 可以试试,不保证能用!

2betop commented 9 years ago

https://github.com/fex-team/fis-velocity-tools/blob/master/src/main/java/com/baidu/fis/servlet/Upload.java

woshiwenzhijie commented 9 years ago

恩 谢谢~