2013年4月25日 星期四

[NodeJS] Auto deploy by github hook

Github hook service會在有新的commit的時候觸發hook API(bitbucket也有), 這可以用在

  • 遠端Server自動部署, 才不用每次都ssh到遠端Server去git pull然後deploy一遍
  • 自動發訊息到團隊的協作平台或是寄發Email
  • ...

Github本身支援很多好用的服務, 那我是用WebHook在我的主機上, 當有commit時會觸發Server上的hook, 然後執行一個Shell Script, 自動git pull然後重新啓動我的Web Service

$ cd /var/web/project
$ git pull
$ forever restart /var/web/project/app.js

Code
https://github.com/hankwang/node-github-hook-deploy


2013年4月2日 星期二

[Linux] 使用 Crontab 定時執行程式

為什麼用 crontab ?

執行例行性的工作, 例:

  • 定期備份資料
  • 定期寄送Server log到某個Email
  • 定期檢查系統狀態

crontab 指令

$ crontab -l # 列出所有 cron jobs
$ crontab -r # 刪除所有 cron jobs
$ crontab -e # 編輯目前使用者的 cron jobs
$ crontab [-u  user] -l # 列出某個使用者的cron jobs (要有權限) 

時間格式 time format

  • minutes 0-59
  • hour 0-23
  • day of month 1-31
  • month 1-12
  • day of week 0-7 (0 or 7 is Sun)

crontab sample


See Also

crontab(5) - Linux man page

[Sublime Text] 我的Sublime Text 2設定檔

高亮目前選取行"highlight_line": true

停用Vintage模式 (Vintage Mode) "ignored_packages": [ "Vintage" ],

Soda樣式的tab"soda_classic_tabs": false

tab的大小"tab_size": 4

把tab轉為空白鍵"translate_tabs_to_spaces": true

存檔時移除不必要的空白"trim_trailing_white_space_on_save": true

偵測跑很慢的plugin, 會跳出警告"detect_slow_plugins": false

完整的設定檔

Related Posts Plugin for WordPress, Blogger...