Uruchomienie aplikacji

Witam,

Mam działającego nginxa, zainstalowałem rubiego, doinstalowałem przez gemy railsy, i chcę lokalnie uruchomić stronę, która produkcyjnie chodzi na serwerze. Skonfigurowałem mongrela:

sudo mongrel_rails cluster::configure -p 8000 -e production -a 127.0.0.1 -N 2 --user mongrel --group mongrel -P /var/run/mongrel_cluster/mongrel.pid -c /var/www/nginx-default/moja_strona/ user@komp$ Writing configuration file to config/mongrel_cluster.yml
Uruchamiam mongrela i mam problem z logami PID:

[code]user@komp$$ mongrel_rails cluster::start
starting port 8000
!!! Path to log file not valid: log/mongrel.8000.log
mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help.

starting port 8001
!!! Path to log file not valid: log/mongrel.8001.log
mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help.[/code]
ale mongrele chodzą:

sudo ps -ef |grep mongrel user 11395 6860 0 13:38 pts/2 00:00:00 grep mongrel
Serwer WWW też chodzi:

 ps -A |grep nginx

6932 ? 00:00:00 nginx 6933 ? 00:00:00 nginx
Plik mongrel_cluster.yml

--- group: mongrel address: 127.0.0.1 log_file: log/mongrel.log port: "8000" cwd: /var/www/nginx-default/moja_strona/ environment: production user: mongrel pid_file: /var/run/mongrel_cluster/mongrel.pid servers: 2
Wchodze w przeglądarke i wpisuje http://127.0.0.1:8000/ i niestety nie łączy mnie z aplikacją. Co robie źle? Sorki, ale średnio się znam na RoR/mongrel/nginx a będe musiał to opanować. Pozdrawiam
Basitan

Powodów może być kilka:

  • sprawdź czy masz katalog log
  • użytkownik mongrel ma do niego prawa
  • wydaje mi się, że bardziej standardowym rozwiązaniem jest trzymanie pidów w tmp/pids, i tu znowu user mongrel może nie mieć uprawnień do tego pliku.

Zobacz sobie tutorial. Dzięki niemu jak już wszystko odpalisz to razem z serwerem będzie też wstawał mongrel_cluster.

Aha nginx sam sobie balansuje mongrele więc to powinno działać na 127.0.0.1

[quote=Bastian]ale mongrele chodzą:

sudo ps -ef |grep mongrel user 11395 6860 0 13:38 pts/2 00:00:00 grep mongrel
[/quote]
Nie chodzą. To tylko proces grep’a którego uruchomiłeś dla wyrażenia ‘mongrel’.
Popraw config/mongrel_cluster.yml tak, by był tam ustawiony log (prawdopodobnie musi być to ścieżka bezwzględna).

Nie musi być ścieżka bezwzględna,

cwd: /sciezka/do/aplikacji

to ustawia kontekst aplikacji. Moim zdaniem to kwestia uprawnień. Taki sam problem miałem 4 dni temu i ustawienie odpowiednich uprawnień wystarczyło.

[quote=Martin_wroc]Powodów może być kilka:

  • sprawdź czy masz katalog log
  • użytkownik mongrel ma do niego prawa
  • wydaje mi się, że bardziej standardowym rozwiązaniem jest trzymanie pidów w tmp/pids, i tu znowu user mongrel może nie mieć uprawnień do tego pliku.

Zobacz sobie tutorial. Dzięki niemu jak już wszystko odpalisz to razem z serwerem będzie też wstawał mongrel_cluster.

Aha nginx sam sobie balansuje mongrele więc to powinno działać na 127.0.0.1[/quote]
Rzeczywiscie utworzenie katalogu /var/www/nginx/nginx-default/moja_strona/log pomoglo:

root@grzempa-desktop:/var/www/nginx-default/moja_strona/# mongrel_rails cluster::start starting port 8000 starting port 8001
w /log pojawiły się logi.

Jednak nadal nie moge odpalić aplikacji przez wpisanie http://127.0.0.1/ czy http://127.0.0.1:8000/

[quote=Bastian]root@grzempa-desktop:/var/www/nginx-default/arconet# mongrel_rails cluster::start starting port 8000 starting port 8001
w /log pojawiły się logi.

Jednak nadal nie moge odpalić aplikacji przez wpisanie http://127.0.0.1/ czy http://127.0.0.1:8000/[/quote]
A co pokazuje ‘ps aux |grep [m]ongrel’?
Zerknij też w logi, może aplikacja zdycha zaraz po starcie.

** Starting Mongrel listening at 127.0.0.1:8000 ** Initiating groups for "mongrel":"mongrel". ** Changing group to "mongrel". ** Changing user to "mongrel". ** Starting Rails with production environment... /usr/lib/ruby/1.8/logger.rb:525:in `initialize': Permission denied - /var/www/nginx-default/moja_strona/log/production.log (Errno::EACCES) from /usr/lib/ruby/1.8/logger.rb:525:in `open' from /usr/lib/ruby/1.8/logger.rb:525:in `create_logfile' from /usr/lib/ruby/1.8/logger.rb:520:in `open_logfile' from /usr/lib/ruby/1.8/logger.rb:487:in `initialize' from /usr/lib/ruby/1.8/logger.rb:263:in `new' from /usr/lib/ruby/1.8/logger.rb:263:in `initialize' from /var/www/nginx-default/moja_strona/config/environment.rb:38:in `new' from /var/www/nginx-default/moja_strona/config/environment.rb:38 from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:95:in `run' from /var/www/nginx-default/moja_strona/config/environment.rb:13 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 from /usr/bin/mongrel_rails:19:in `load' from /usr/bin/mongrel_rails:19

** Starting Mongrel listening at 127.0.0.1:8001 ** Initiating groups for "mongrel":"mongrel". ** Changing group to "mongrel". ** Changing user to "mongrel". ** Starting Rails with production environment... /usr/lib/ruby/1.8/logger.rb:525:in `initialize': Permission denied - /var/www/nginx-default/moja_strona/log/production.log (Errno::EACCES) from /usr/lib/ruby/1.8/logger.rb:525:in `open' from /usr/lib/ruby/1.8/logger.rb:525:in `create_logfile' from /usr/lib/ruby/1.8/logger.rb:520:in `open_logfile' from /usr/lib/ruby/1.8/logger.rb:487:in `initialize' from /usr/lib/ruby/1.8/logger.rb:263:in `new' from /usr/lib/ruby/1.8/logger.rb:263:in `initialize' from /var/www/nginx-default/moja_strona/config/environment.rb:38:in `new' from /var/www/nginx-default/moja_strona/config/environment.rb:38 from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:95:in `run' from /var/www/nginx-default/moja_strona/config/environment.rb:13 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 from /usr/bin/mongrel_rails:19:in `load' from /usr/bin/mongrel_rails:19

/usr/lib/ruby/1.8/logger.rb:525:in `initialize': Permission denied - /var/www/nginx-default/moja_strona/log/production.log (Errno::EACCES)

Zanim zajrzałem do logów uruchomiłem (a przynajmniej spróbowałem) uruchomic mongrela z roota…

chown -R mongrel:mongrel /var/www/nginx-default/moja_strona/log/

Zrobioe, teraz mam:

** Starting Mongrel listening at 127.0.0.1:8000 ** Initiating groups for "mongrel":"mongrel". ** Changing group to "mongrel". ** Changing user to "mongrel". ** Starting Rails with production environment... /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `read': No such file or directory - /var/www/nginx-default/moja_strona/config/database.yml (Errno::ENOENT) from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `database_configuration' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:340:in `initialize_database' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:124:in `process' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `send' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `run' from /var/www/nginx-default/moja_strona/config/environment.rb:13 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 from /usr/bin/mongrel_rails:19:in `load' from /usr/bin/mongrel_rails:19

[quote=Bastian]Zrobioe, teraz mam:

** Starting Mongrel listening at 127.0.0.1:8000 /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `read': No such file or directory - /var/www/nginx-default/moja_strona/config/database.yml (Errno::ENOENT)
[/quote]
A masz taki plik? I czy poprawnie opisuje konfigurację Twojej bazy danych? [[Pytania retoryczne: nie, nie masz tego pliku i w tym problem!]]

[quote=hubertlepicki][quote=Bastian]Zrobioe, teraz mam:

** Starting Mongrel listening at 127.0.0.1:8000 /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `read': No such file or directory - /var/www/nginx-default/moja_strona/config/database.yml (Errno::ENOENT)
[/quote]
A masz taki plik? I czy poprawnie opisuje konfigurację Twojej bazy danych? [[Pytania retoryczne: nie, nie masz tego pliku i w tym problem!]][/quote]
No nie mam tego pliku, to oczywiste, ale pewnie utworzenie pustego o takiej nazwie, na nic się zda, a bazy danych nie mam. Pytanie czy musze stawiać postgresa, żeby w ogóle odpalić tą stronę?? Nie potrzebuje żadnej zawartości, chodzi mi o wyświetlanie html+css.

Jeśli nie masz żadnej zawartości (ani bazy ani modeli) w pliku config/environment.rb możesz wyłączyć ActiveRecord"

[code=Ruby]Rails::Initializer.run do |config|

tu masz inne ustawienia, dodaj tę linijkę poniżej, ważne, żeby była wewnątrz bloku Rails::Initializer

config.frameworks -= [:active_record]
end[/code]

Odhashowałem linie:

config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

I teraz mam:

[/CODE]/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:493:in
`const_missing’: uninitialized constant CGI::Session::ActiveRecordStore (NameError)
[/CODE]

Czyli jednak bez stawiania postgresa się nie obędzie ?

a nie masz przypadkiem czegoś ustawionego w config/initializers/session_store ? sesja Ci w sumie nie potrzebna

[quote=Bastian]Odhashowałem linie:

config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

I teraz mam:

[/CODE]/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:493:in
`const_missing’: uninitialized constant CGI::Session::ActiveRecordStore (NameError)
[/CODE]

Czyli jednak bez stawiania postgresa się nie obędzie ?[/quote]
Jeśli to jest problem (jedyny) to się obędzie. Możesz ustawić np. na cookies store i powinno (ale nie musi) śmigać.

Schody mogą się zacząć jeśli masz jakieś modele. app/models/ jest pusty?

Ciężko mi wyobrazić sobie jakąkolwiek sensowną aplikację RoR która nie korzystała by z jakiejś bazy danych, nie wiem co tam masz ale to wygląda na jakieś programistyczne Yeti.

[quote=hubertlepicki][quote=Bastian]Odhashowałem linie:

config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

I teraz mam:

[/CODE]/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:493:in
`const_missing’: uninitialized constant CGI::Session::ActiveRecordStore (NameError)
[/CODE]

Czyli jednak bez stawiania postgresa się nie obędzie ?[/quote]
Jeśli to jest problem (jedyny) to się obędzie. Możesz ustawić np. na cookies store i powinno (ale nie musi) śmigać.

Schody mogą się zacząć jeśli masz jakieś modele. app/models/ jest pusty?

Ciężko mi wyobrazić sobie jakąkolwiek sensowną aplikację RoR która nie korzystała by z jakiejś bazy danych, nie wiem co tam masz ale to wygląda na jakieś programistyczne Yeti.[/quote]
hehe, żadne programistyczne Yeti, normalnie chodząca strona. Potrzebuje zmienić tylko layout na html/css i chce to zrobić pierw lokalnie. Dobra, rozumiem, że musze najlepiej postawić całość. Rozumiem, że również struktura bazy (tabele, widoki itp) będą musiały być zaimportowane ?

Jane że będą musiały ;). Railsowa aplikacja jeśli nie ma stworzonej bazy danych i tabel do modeli wcale nie ruszy.

Ok, dzieki. Na PHP+Apache+baza danych jednak wygląda to troche inaczej :wink:

Pozdrawiam

Uruchomiłem postgresa, utworzyłem identycznego usera oraz role jak na serwerze produkcyjnym, utworzylem taka sama baze danych (nazwa) i zaimportowałem strukturę bazy (bez rekordów). Jednak nadal dostaje:

** Starting Mongrel listening at 127.0.0.1:8001 ** Initiating groups for "mongrel":"mongrel". ** Changing group to "mongrel". ** Changing user to "mongrel". ** Starting Rails with production environment... /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `read': \ No such file or directory - /var/www/nginx-default/strona/config/database.yml (Errno::ENOENT) from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:716:in `database_configuration' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:340:in `initialize_database' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:124:in `process' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `send' from /usr/lib/ruby/gems/1.8/gems/rails-2.1.2/lib/initializer.rb:97:in `run' from /var/www/nginx-default/strona/config/environment.rb:13 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run' from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 from /usr/bin/mongrel_rails:19:in `load' from /usr/bin/mongrel_rails:19

Ten fragment jest kluczowy:

No such file or directory - /var/www/nginx-default/strona/config/database.yml (Errno::ENOENT)