Joyent no.de 试用和配置笔记
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:admin 阅读 389
配置1)提交一个sshpubkey。2)windows中可能没有sshconfig文件,先要在%home%.ssh下新建config文件,内容写入:Hostambar.no.dePort18360U

配置

1) 提交一个 ssh pub key。

2) windows 中可能没有 ssh config 文件,先要在 %home%.ssh 下新建 config 文件,内容写入:

Host ambar.no.de    Port 18360    User node    ForwardAgent yes  

3) 命令行 ssh 登入,这里用的是我喜欢的 powershell :

PS C:\Users\lj> ssh ambar.no.de  Last login: Sat Dec 17 03:41:31 2011 from 10.2.136.43               __                       __                      __      __      / /___  __  _____  ____  / /_   ____  ____   ____/ /__   __/ /___  / / __ \/ / / / _ \/ __ \/ __/  / __ \/ __ \ / __  / _ \  /_  __/ /_/ / /_/ / /_/ /  __/ / / / /_   / / / / /_/ // /_/ /  __/   /_/  \____/\____/\__, /\___/_/ /_/\__/  /_/ /_/\____(_)__,_/\___/                   /____/  Welcome to ambar.no.de    Useful Commands:   pkgin -h   node-service-info   node-service-log   node-service-restart   node-service-disable   node-service-enable   node-service-howto    Useful URLs:   http://wiki.joyent.com/display/node/Node+SmartMachine+FAQ   https://no.de/   http://nodejs.org/docs/latest/api/   https://api.no.de/  

no.de 的 SmartMachine 比 heroku 好用就在这里,让你感觉你有一个真正的机器,不用麻烦地去记忆 heroku 的命令。

先看看运行的 nodejs 版本:

[node@ambar ~]$ node  process.versions  { node: '0.4.11',    v8: '3.1.8.26',    ares: '1.7.4',    ev: '4.4',    openssl: '0.9.8k' }  

从 node-service-info 命令可以看到默认运行服务器位置和参数:
> /opt/nodejs/v0.4/bin/node /opt/nodejs/default_server/server.js

通过 pkgin 可以很方便地安装软件:
> http://wiki.joyent.com/display/smart/Installing+Software+on+a+SmartMachine

4) 新建本地 repo , 新建 app.js,push 测试代码:

git push ambar.no.de master  Counting objects: 3, done.  Delta compression using up to 4 threads.  Compressing objects: 100% (2/2), done.  Writing objects: 100% (3/3), 353 bytes, done.  Total 3 (delta 0), reused 0 (delta 0)  remote: Deploying node-service.  remote:     revision:  51027adfaeb07b11b7b84f938fe729002fcefafd  remote:     timestamp: 2011-12-17T04-33-02.424359254  remote: error: Cannot deploy without either a 'package.json' or 'server.js'.  remote: See <http://wiki.joyent.com/display/node/Node+Home> for more info.  remote:  remote: Rolling back to default server.  remote: Starting node-service.  remote: Rollback succeeded.  To ambar.no.de:repo   * [new branch]      master -> master  

出错了! 默认服务器引导的文件必须名叫 server.js ,否则用 package.json 文件进行配置:
> http://wiki.joyent.com/display/node/Getting+Started+with+a+Node.js+SmartMachine

要紧的是 package.json 必须符合标准格式:

要动手写一个的,参考 express 的最直接:

https://github.com/visionmedia/express/blob/master/package.json

package.json 样例:

{  "name"       : "ambar.no.de",  "version"    : "0.0.1",  "description": "have fun with no.de",  "scripts"    : { "start": "node ./app" }  }  

或者更酷一点,可以在 ssh 中用 npm 安装 CoffeeScript:

npm install -g coffee-script  // 用 coffee 引导应用:  { "start": "coffee ./app" }  
http = require 'http'  port = process.env.PORT || 80    http.createServer (req,res) ->     res.writeHead 200, {'Content-Type': 'text/plain'}    res.end 'Hello World\n'  .listen port    console.log "Listening on port " + port  

再 push 一遍,应用就成功运行了。

如何设置 node 版本:
> http://wiki.joyent.com/display/node/Setting+the+Node.js+Version

简易的方式是新建一个 config.json 文件,内容如下:

{ "version": "latest" }  

查看所有可用的 nodejs 版本:

cat /opt/nodejs/NODE-BUILDS  
联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2