Heroku send by Gmail
在Rails上透過Gmail寄信是蠻簡單的.
但網站搬到Heroku後最近發現似乎寄信有問題?
一查之下才知道要裝套件,官方網站其實就有,不過自己還是做個紀錄.
1.Install Plugin
$ script/plugin install git://github.com/adamwiggins/gmail_smtp.git
2.設定帳號
$ export GMAIL_SMTP_USER=username@gmail.com $ export GMAIL_SMTP_PASSWORD=yourpassword
3.設定Heroku
$ heroku config:add GMAIL_SMTP_USER=username@gmail.com $ heroku config:add GMAIL_SMTP_PASSWORD=yourpassword
完成.
搬移專案到Heroku. 疑難雜症.
原本使用Hosting Rails. 最近因為官方升級,很多問題.
做為一個主機商,一兩天就算了. 一週實在太超過.
版上抱怨也都得沒到解決,發Email連收也沒收到,只差沒打電話..
怕SliceHost也會有類似問題,而且也是一次先預付..索性將專案搬移到Heroku. 使用量到才需要付多一點.
過程遇到一些問題,紀錄一下.
ssh-key問題 :
$ heroku clone hobocookbook [/Data/Rails] [DrTeeth] Initialized empty Git repository in /Data/Rails/hobocookbook/.git/ The authenticity of host 'heroku.com (75.101.141.116)' can't be established. RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'heroku.com,75.101.141.116' (RSA) to the list of known hosts. Permission denied (publickey). fatal: The remote end hung up unexpectedly ...以下省略
解法 :
heroku keys:clear; sudo ssh-keygen -t rsa; heroku keys:add /root/.ssh/id_rsa.pub
然後再做你原本想做的事情.
taps (for Database Upload) 問題 :
~$ sudo gem install taps
[sudo] password for mike:
Building native extensions. This could take a while…
ERROR: Error installing taps:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install taps
checking for fdatasync() in -lrt… yes
checking for sqlite3.h… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
...以下省略
解法 :
sudo aptitude install libsqlite3-dev libsqlite3-doc
taps 無法上傳 :
$ heroku db:push "~/xxx/db/xxx.sqlite3" Loaded Taps v0.3.5 Warning: Data in the app 'xxx' will be overwritten and will not be recoverable. Are you sure you wish to continue? (y/n)? y Failed to connect to database: ArgumentError -> interning empty string
解法 :
heroku db:push --app yourappname
這個最蝦. - -
Heroku is a great host for RoR. But still has some problems
Heroku的簡便,其實也造就了他的問題.
因為不是第一次被人推薦了,所以就去官網上看看.
不過,看了就覺得並不是太想用.
除了價格昂貴,再來就是他的優點,其實也是缺點.
Heroku的優點是兩面刃
由於你只要註冊好Heroku,然後 :
sudo gem install heroku
heroku create yourapp
當你要建好專案要上傳 :
git push heroku
就上傳好了
當要做些工作,比如migrate :
heroku domains:add yourdomain.com #(加網域名,應該是加到DNS?) heroku rake db:migrate heroku bundles:capture
可是,他的方便也是不便.
我是不太喜歡一直和Host方溝通,比較喜歡一次就擁有很多自主權.
所以,當有問題,我該寫信去???
問題1, 如果想增加sub domain? 更改MX records,CName,etc...?
問題2, 原先配置為Thin+Nginx. 若想改用其他?
問題3, 目前尚未支援Custom SSL.
問題4, 太貴....
問題5, 還沒想到. 如果你有解答,歡迎討論互動.
就像Xdite說的,在我看來,現在還是Project比較適合. 若要Production,太貴,也不太適合.
--後記 :
初碰Heroku可能面臨問題.
Q : Install?
A : $>sudo gem install heroku
Q : Create?
A : $>git init
$>heroku create
Q : Upload?
A : $>git push heroku YouBranchName(master)
Q : See?
A : $>heroku open
Q : No ssh public key found in /root/.ssh/id_[rd]sa.pub. You may want to specify the full path to the keyfile.
A : ssh-keygen -t rsa
Q : Move Database?
A : $>sudo gem install taps
$>heroku db:push
Q : Rename App?
A : $>git remote rm heroku
$>git remote add git@heroku.com:YOURAPPNAME.git
Q : Manage Custom Gems?
A : 1. Create a file ".gems" under folder
2. Add "yourgem --version x.x.x --source xxxxxxxx" (ex : geokit --version '>=1.5.0' )
Each Gem one line.
3. "git commit -a" & "git push heroku xxx"

