coffeeScript实时同步到服务器,自动编译并重启nodejs服务
利用Sublime的SFTP工具实现coffeeScript同步到服务器并自动编译成js,自动重启node服务
安装Sublime SFTP/FTP 工具
- Sublime -> Tools -> Package Control -> install package ->sftp
在指定目录下新建sftp-config.json
{ // The tab key will cycle through the settings when first created // Visit http://wbond.net/sublime_packages/sftp/settings for help // sftp, ftp or ftps "type": "sftp", "save_before_upload": true, "upload_on_save": true, "sync_down_on_open": false, "sync_skip_deletes": false, "sync_same_age": true, "confirm_downloads": false, "confirm_sync": false, "confirm_overwrite_newer": false, "host": "服务器ip", "user": "服务器用户名", "password": "服务器密码", //"port": "22", "remote_path": "服务器上对应目录", "ignore_regexes": [ "\\.sublime-(project|workspace)", "sftp-config(-alt\\d?)?\\.json", "sftp-settings\\.json", "/venv/", "\\.svn/", "\\.hg/", "\\.git/", "\\.bzr", "_darcs", "CVS", "\\.DS_Store", "Thumbs\\.db", "desktop\\.ini" ], //"file_permissions": "664", //"dir_permissions": "775", //"extra_list_connections": 0, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ftp_obey_passive_host": false, //"ssh_key_file": "~/.ssh/id_rsa", //"sftp_flags": ["-F", "/path/to/ssh_config"], //"preserve_modification_times": false, //"remote_time_offset_in_hours": 0, //"remote_encoding": "utf-8", //"remote_locale": "C", //"allow_config_upload": false, }
- 右键该文件夹或其下文件sftp/ftp上传或同步文件,同时修改该目录下文件保存后便会自动上传同步
服务器上coffee文件同步编译
- 在服务器上
npm install -g coffee-script
需要nodejs和npm支持 - 在服务器相应目录下coffee –watch –compile <文件>,实时监控该文件,具体参数请看coffeeScript
nodejs+express搭建web服务器
- express生成器安装
npm install express-generator -g
- 直接在指定目录下express myapp 生成相应文件 myapp为项目名称
- cd myapp&&npm install 安装所需要包
- DEBUG=myapp npm start 就可以在 http://localhost:3000/ 查看相应内容
supervisor 实时监控文件变化并且在服务器出错时重启
- npm -g install supervisor安装
- 打开上文myapp所在package.json文件
- 在script下加入或直接修改
"start": "supervisor -w ./ -x node ./bin/www "
www为exress生成文件
完成以上步骤后当在本地编辑保存后,服务器即时生效,即时查看效果