신선한 웹 OSX 라이온에 silkjs의 설치 :
[email protected]:~/src$ curl http://silkjs.org/install-osx.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1666 100 1666 0 0 3553 0 --:--:-- --:--:-- --:--:-- 79333
Installing SilkJS in /usr/local/silkjs
You may be asked to enter your password.
This is so the /usr/local directory can be made writable for the install.
Password:
Downloading SilkJS
######################################################################## 100.0%
Installation complete.
You need to add /usr/local/bin to your PATH environment variable.
This can be done by adding this line to your .bashrc file:
export PATH=/usr/local/bin:$PATH
You can run SilkJS with the following command:
$ silkjs
You can run the SilkJS HTTP Server with the following command:
$ httpd-silk.js yourapp.js
For instructions on setting up a WWW site for httpd-silk.js, see
http://silkjs.org/http-server/
를 지금은 작동보고 :
[email protected]:~/src$ silkjs
SilkJS> console.dir(require('MySQL'));
undefined line 1 (eval):
function() {
this.queryCount = 0;
this.handle = null;
}
undefined
SilkJS>
참고 console.dir() 함수를 보여줍니다. 나머지 메서드는 함수의 속성 (생성자)으로 정의됩니다. 그래서 당신은 MySQL의() 객체를 생성해야합니다
SilkJS> var mysql = require('MySQL');
SilkJS> m = new mysql();
SilkJS> console.log(m.connect)
function (host, user, passwd, db) {
if (!this.handle) {
host = host || Config.mysql.host;
user = user || Config.mysql.user;
passwd = passwd !== undefined ? passwd : Config.mysql.passwd;
db = db || Config.mysql.db;
this.handle = mysql.connect(host, user, passwd, db);
}
}
undefined
SilkJS>
이제 연결하려면, 당신은 호스트, 사용자, passwd 파일 및 DB를 전달해야합니다. 또는 httpd 환경에서 실행중인 경우 Config.mysql을 다음과 같이 설정합니다. Config.mysql = { 호스트 : 'localhost'또는 // MySQL 서버를 실행하는 다른 호스트 user : 'someuser', // 사용자 이름이 MySQL 서버에 passwd를 인증하기 : 는 DB MySQL 서버의 '무엇', // 사용자 이름의 암호 'database_name은 "// MySQL 서버에서 데이터베이스의 이름} 에 연결,
을 그 다음 HTTP 서버는 요청에 따라 요청할 수있는 전역 SQL 객체를 생성합니다. 이것은 자동으로 SQL.getDataRows(), SQL.getScalar() 등을 사용할 수 있습니다 ..
SilkJS를 다시 설치하고 descr 'test'데이터베이스를 포함하는 깨끗한 mysql 설치에서 m.connect ('localhost', 'root', '', 'test')를 사용하여 위의 ibed를 수행한다. 나는 여전히 (명백한) 오류가 있으며 segfault가 startTransaction()을 호출 할 때마다 오류가 발생한다. 문제없이 mysql5 클라이언트를 사용하여 연결할 수 있습니다 : $ mysql5 -u root -p test –
문제점을 발견했습니다. 호스트 이름 대신 localhost 대신 127.0.0.1을 사용하는 것을 잊었습니다. 다시 말해 : SilkJS> m.connect ('127.0.0.1', 'root', '', 'test') 이제는 훌륭하게 작동합니다. –