无法在 SmartOS 上使用 SMF 为 Node 设置 blueimp jquery 上传服务器

无法在 SmartOS 上使用 SMF 为 Node 设置 blueimp jquery 上传服务器

我设立了一个node blueimp jquery 文件上传服务器在 Joyent 云 SmartOS SmartMachine(nodejs 13.1.0)实例上。

如果我使用命令 ./node_modules/blueimp-file-upload-node/server.js 手动启动它,它可以正常工作。

但是,如果使用 SMF 启动它,服务器能够回复 GET 并传送图片,但无法接受 POST 并中断。以下是模板清单、客户端和服务器错误日志。任何有关如何创建清单以允许接收 POST 的帮助都将不胜感激。

浏览器 POST 时所有清单的常见错误

Request URL:
http://sub1.mydomain.com:8888/node_modules/blueimp-file-upload-node/server.js
Request Headers CAUTION: Provisional headers are shown.
Accept:
application/json, text/javascript, */*; q=0.01
Content-Type:
multipart/form-data; boundary=----WebKitFormBoundary4x1QBIUsPyFwN0xP
Origin:
http://sub1.mydomain.com
Referer:
http://sub1.mydomain.com
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.19 Safari/537.36
 Request Payload
 ------WebKitFormBoundary4x1QBIUsPyFwN0xP
Content-Disposition: form-data; name="send-message"

 ------WebKitFormBoundary4x1QBIUsPyFwN0xP
Content-Disposition: form-data; name="files[]"; filename="84a0ff8ef9ba11e1afba1231380fc0f9_7.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary4x1QBIUsPyFwN0xP--

SMF 仅体现了我在每种情况下第一个之后所做的更改:

SMF 以 root 身份出现 - exec 时没有 /opt/local/bin/node

<service_bundle type="manifest" name="kamkam">
<service name="site/kamkam-service" type="service" version="1">
<create_default_instance enabled="true"/>
<single_instance/>
<dependency name="network" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/milestone/network:default"/>
</dependency>
<dependency name="filesystem" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/system/filesystem/local"/>
</dependency>

<method_context working_directory="/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node">
<method_credential user="root"/>
<method_environment>
  <envvar name="PATH" value="/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin"/>
  <envvar name="HOME" value="/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node"/>
  <envvar name="NODE_ENV" value="production"/>
</method_environment>
</method_context>

<exec_method
type="method"
name="start"
exec="/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/server.js"
timeout_seconds="60"/>

<exec_method
type="method"
name="stop"
exec=":kill"
timeout_seconds="60"/>

<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="child"/>
<propval name="ignore_error" type="astring" value="core,signal"/>
</property_group>

<property_group name="application" type="application">
</property_group>

<stability value="Evolving"

错误:root 用户在 exec 时没有 /opt/local/bin/node

/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-    node/node_modules/formidable/lib/incoming_form.js:28
  this.uploadDir = opts.uploadDir || os.tmpDir();
                                    ^
TypeError: Object #<Object> has no method 'tmpDir'
at new IncomingForm (/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload- node/node_modules/formidable/lib/incoming_form.js:28:41)
at [object Object].post (/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/server.js:211:20)
at Server.<anonymous> (/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/server.js:134:25)
at Server.emit (events.js:67:17)
at HTTPParser.onIncoming (http.js:1124:12)
at HTTPParser.onHeadersComplete (http.js:108:31)
at Socket.ondata (http.js:1019:22)
at Socket._onReadable (net.js:683:27)
at IOWatcher.onReadable [as callback] (net.js:177:10)

SMF 清单作为管理员 - 所有文件权限

<method_credential user="admin" group="staff" privileges="basic,net_privaddr,file_chown,file_chown_self,file_dac_read,file_dac_search,file_dac_write,file_owner"/>

exec="/opt/local/bin/node /home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/server.js"

管理员所有文件权限错误

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: EACCES, open '/home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/tmp/09008ecbfafd1c3570eff7ae0ae52fa8'
[ Nov 25 15:41:29 Stopping because all processes in service exited. ]

SMF 在 exec 时使用 /opt/local/bin/node 以 root 身份出现

<method_credential user="root"/>
exec="/opt/local/bin/node /home/projects/egoer/sub1.mydomain.com/node_modules/blueimp-file-upload-node/server.js"

根用户错误 - 在 exec 时使用 /opt/local/bin/node

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: spawn ENOENT
at errnoException (child_process.js:975:11)
at Process.ChildProcess._handle.onexit (child_process.js:766:34)
 [ Nov 25 16:00:16 Stopping because all processes in service exited. ]

相关内容