Instalacja Slanger na Ubuntu

Z Podręcznik Administratora by OPZ SGU
Przejdź do nawigacji Przejdź do wyszukiwania
Wersja do druku nie jest już wspierana i może powodować błędy w wyświetlaniu. Zaktualizuj swoje zakładki i zamiast funkcji strony do druku użyj domyślnej funkcji drukowania w swojej przeglądarce.

Tłumaczenie ze strony (http://techblog.willshouse.com/2013/05/16/install-slanger-on-ubuntu-12/)


I wanted to install it on Ubuntu 12 but hit a few snags, so here’s how I got it working.


First, it seems pretty imperative that you have a good ruby version manager (rvm) tool available. On Mac OS X I use rbenv but on Ubuntu I think the best one is the one from https://get.rvm.io and not the one from apt-get.


So if you have installed the one from apt-get then it is probably best to remove it. Disclaimer – back up important files, blah bla blah, you should have some knowledge of linux, bla bla bla, I don’t know what you might accidentally delete while doing this. Be careful.


To remove the old rvm:


<code>sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh
</code>

Then logout of the shell and/or reboot and run:


<code>env | grep rvm
</code>

It should be blank, but if not try and find where the settings are coming from. I changed to the /etc/ directory and ran grep -Hil rvm and found that it was in the bash.profile there so i removed the environmental variables being set there, then logged out of my shell and logged in again.


Once that is removed, you need to install the new version of rvm and from the website get.rvm.io the instructions say run this:


<code>\curl -L https://get.rvm.io | 
    bash -s stable --ruby --autolibs=enable --auto-dotfiles
</code>

That worked great, I think it installed ruby 2.0 by default and I think it would be better to have 1.9.3 so I ran:


<code>rvm install 1.9.3
</code>

After that completed I wanted to make 1.9.3 run as my default so I ran:


<code>rvm use 1.9.3 --default
</code>

Next – PLEASE READ CAREFULLY BEFORE EXECUTING – I ran the following command which GAVE ME SOME ERRORS:


<code>gem install slanger
</code>

Slanger 0.3.7 has some issues with version dependencies with rack and sinatra and so the command spit out:


<code>ERROR:  While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: slanger requires rack (~> 1.5);
thin requires rack (>= 1.0.0); sinatra requires rack (< 1.5, ~> 1.1)
</code>

You may be able to run that command without any problem (after slanger is updated) but as of right now you need to install an older version of slanger IF THE PREVIOUS COMMAND DOES NOT WORK.


So you can try:


<code>gem install slanger -v=0.3.6
</code>

You also need to have redis-server so run:


<code>gem install redis-server
</code>

Next you can start the redis-server with:


<code>redis start
</code>

Similarly you can stop redis with


<code>redis stop // don't run this right now - it's in case you need it later
</code>

If everything worked well you can just run slanger with:


<code>slanger --app_key 765ec374ae0a69f4ce44 --secret your-pusher-secret
</code>

But if that gives you an error about:


<code>/usr/local/rvm/gems/ruby-1.9.3-p429/gems/slanger-0.3.6/bin/slanger:106:
in `block in <top (required)>': uninitialized constant Slanger::VERSION (NameError)
</code>

Then you need to make a small edit until slanger is updated.


Edit the file referenced in the error, at the line referenced (106):


<code>/usr/local/rvm/gems/ruby-1.9.3-p429/gems/slanger-0.3.6/bin/slanger
</code>

And it has this line of code:


<code>puts "Running Slanger v.#{Slanger::VERSION}"
</code>

I just commented that line out


<code>#puts "Running Slanger v.#{Slanger::VERSION}"
</code>

And voila it works!


<code>Slanger API server listening on port 4567
Slanger WebSocket server listening on port 8080
</code>

The github issues page is also a good resource but just don’t try and install slanger inside inside another app. Read the readme:


<code>Slanger is intended as a server that is easy to install,
not a gem inside Rails or Sinatra.
</code>