Info16.fr

Le blog de B@rtounet

node.js

#Gnu/Linux, Planet Libre

Scrumblr : Tableau collaboratif en ligne

srumblr
  scrumblr logo

Scrumblr vous offre la possibilité de créer un tableau blanc collaboratif sous forme de Post-it de toutes les couleurs.
L'application en ligne sur vos serveur offre un environnement graphique simple d'utilisation sans enregistrement préalable.

Plateforme Materielle :



Comme d'habitude, j'ai monté mon prototype sur ma plateforme de virtualisation:

Dedibox Pro HP
Plateforme logicielle hyperviseur:
  • Dom0 Ubuntu 12.04 X86_64 Xen 4.1
Plateforme Virtuelle:

  • DomU Xen Ubuntu 12.04 X86_64 Paravirtualisé
  • 2 vcpus 
  • 512 Mo de Ram
  • HDD 16GB


Installation:

Scrumblr demande quelques prérequis:
redis v2.2.2
node.js >= 0.4.7

En effet scrumblr se base sur redis : Redis (de l'anglais REmote DIctionary Server qui peut-être traduit par « serveur de dictionnaire distant » et jeu de mot avec Redistribute1) est un système de gestion de base de données clef-valeur scalable, très hautes performances, écrit avec le langage de programmation C ANSI et distribué sous licence BSD. Il fait partie de la mouvance NoSQL et vise à fournir les performances les plus élevées possibles.

  • Installation des prérequis
root@antony-linux:/home/antony# apt-get install git-core build-essential

  • Installation de node.js
On télécharge la dernière version de node.js et on la compile
Attention, ethercalc n'est pour l'instant pas compatible avec node.js v9
On utilise la version packagée dans ubuntu 12.04 : nodejs_0.6.12
    root@antony-linux:/home/antony# apt-get install nodejs npm

    root@ubuntu:/# node --version
    v0.6.12
    root@ubuntu:/# npm --version
    1.1.4

  • Installation de redis
On télécharge la version 2.6.4 sur http://redis.io/download

root@ubuntu:/opt#cd /opt
root@ubuntu:/opt# wget http://redis.googlecode.com/files/redis-2.6.4.tar.gz
root@ubuntu:/opt# tar xvfz redis-2.6.4.tar.gz
mv redis-2.6.4 redis
root@ubuntu:/opt# cd /opt/redis/

root@ubuntu:/opt/redis# make

root@ubuntu:/opt/redis# cd src/
root@ubuntu:/opt/redis/src# ./redis-server
[18712] 12 Nov 16:21:00.849 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
[18712] 12 Nov 16:21:00.850 * Max number of open files set to 10032
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.4 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 18712
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'

[18712] 12 Nov 16:21:00.851 # Server started, Redis version 2.6.4
[18712] 12 Nov 16:21:00.851 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[18712] 12 Nov 16:21:00.851 * The server is now ready to accept connections on port 6379

Bon ok redis tourne
Cf Wikipedia: Une des principales caractéristiques de Redis est de conserver l'intégralité des données en RAM. Cela permet d'obtenir d'excellentes performances en évitant les accès disques, particulièrement coûteux.

Lorsque la taille des données est trop importante pour tenir en mémoire, Redis peut également utiliser de la mémoire virtuelle.

Afin d'assurer la conservation des données en cas d'incident — la mémoire vive étant volatile — Redis offre la possibilité de « capturer » l'état de la base dans un fichier. Cette technique ne permettant pas de garantir la conservation des manipulations effectuées entre deux captures, il est également possible de conserver une trace de toutes ces manipulations. En cas d'incident, la base peut être restaurée en les ré-appliquant dans l'ordre.

On va donc modifier la conf pour le rendre persistent:
On modifie le redis.conf
daemonize yes
pidfile /var/run/redis.pid
logfile /var/log/redis.log

port 6379
bind 127.0.0.1
timeout 300

loglevel notice

## Default configuration options
databases 16

save 900 1
save 300 10
save 60 10000

rdbcompression yes
dbfilename dump.rdb

dir /opt/redis/

glueoutputbuf yes


##Persistence
appendonly yes
appendfsync everysec


root@antony-linux:/home/antony# /opt/redis/redis-cli bgrewriteaof

Redis de base ne démarre pas automatiquement... c'est un peu balot.
Il faut créer un  script d'init.
On crée d'abord un user "redis"
root@ubuntu:/etc/init.d# adduser --system --no-create-home --disabled-login --disabled-password --group redis

root@ubuntu:/etc/init.d# chown -R redis /opt/redis

Mon script d'init:

#!/bin/sh

### BEGIN INIT INFO
# Provides: ethercalc
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts ethercalc
# Description: starts ethercalc lite using start-stop-daemon
### END INIT INFO

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/redis.log"
CONFFILE="/opt/redis/redis.conf"
EPLITE_DIR="/opt/redis/src/redis-server"
USER="redis"
GROUP="redis"
DESC="redis"
NAME="redis"

set -e

. /lib/lsb/init-functions

start() {
echo "Starting $DESC... "

start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR -- $CONFFILE || true
echo "done"
}

#We need this function to ensure the whole process tree will be killed
killtree() {
local _pid=$1
local _sig=${2-TERM}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child} ${_sig}
done
kill -${_sig} ${_pid}
}

stop() {
echo "Stopping $DESC... "
while test -d /proc/$(cat /var/run/$NAME.pid); do
killtree $(cat /var/run/$NAME.pid) 15
sleep 0.5
done
rm /var/run/$NAME.pid
echo "done"
}

status() {
status_of_proc -p /var/run/$NAME.pid "" "$NAME" && exit 0 || exit $?
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $NAME {start|stop|restart|status}" >&2
exit 1
;;
esac

exit 0

root@ubuntu:/etc/init.d# update-rc.d redis defaults
Adding system startup for /etc/init.d/redis ...
/etc/rc0.d/K20redis -> ../init.d/redis
/etc/rc1.d/K20redis -> ../init.d/redis
/etc/rc6.d/K20redis -> ../init.d/redis
/etc/rc2.d/S20redis -> ../init.d/redis
/etc/rc3.d/S20redis -> ../init.d/redis
/etc/rc4.d/S20redis -> ../init.d/redis
/etc/rc5.d/S20redis -> ../init.d/redis



root@ubuntu:/etc/init.d# /etc/init.d/redis start

root@ubuntu:/etc/init.d# ps aux | grep redis
redis 19666 0.3 0.3 34900 1724 ? Ssl 17:05 0:00 /opt/redis/src/redis-server /opt/redis/redis.conf


Une bonne chose de faite.
Redis se lance
 
  • Installation de Scrumblr
On utilse git pour récupérer la dernière version.
root@ubuntu:~# cd /opt/
git clone https://github.com/aliasaria/scrumblr.git

Avant toute chose modifier le package.json ("express": ">2.4.x",)
{
"name": "scrumblr",
"description": "Web-based simulation of a physical agile sprint board that supports real-time collaboration.",
"version": "0.1.0",
"repository": {
"url": "http://github.com/aliasaria/scrumblr"
},
"author": "Ali Asaria",
"main": "server.js",
"directories": {
"lib": "lib/"
},
"engines": {
"node": "0.4.7"
},
"dependencies": {
"async": "0.1.x",
"connect": "1.7.x",
"redis-client": "0.3.x",
"redis": "0.6.x",
"sanitizer": "0.0.x",
"socket.io": "0.8.x",
"simplesets": "1.1.x",
"connect-redis":"1.0.x",
"express": ">2.4.x",
"jade": "0.14.x"
}
}




root@ubuntu:~# cd /opt/scrumblr

root@ubuntu:/opt/scrumblr# npm install
npm http GET https://registry.npmjs.org/redis-client
npm http GET https://registry.npmjs.org/sanitizer
npm http GET https://registry.npmjs.org/express/2.4.5
npm http GET https://registry.npmjs.org/jade
npm http GET https://registry.npmjs.org/simplesets
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/connect-redis
npm http GET https://registry.npmjs.org/redis
npm http GET https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/redis-client
npm WARN redis-client@0.3.5 package.json: bugs['web'] should probably be bugs['url']
npm http 304 https://registry.npmjs.org/sanitizer
npm http 304 https://registry.npmjs.org/simplesets
npm http 304 https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/connect/-/connect-1.7.3.tgz
npm http 304 https://registry.npmjs.org/connect-redis
npm http GET https://registry.npmjs.org/connect-redis/-/connect-redis-1.0.7.tgz
npm http 304 https://registry.npmjs.org/redis
npm http 200 https://registry.npmjs.org/express/2.4.5
npm http GET https://registry.npmjs.org/redis/-/redis-0.6.7.tgz
npm http GET https://registry.npmjs.org/express/-/express-2.4.5.tgz
npm http 304 https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/socket.io/-/socket.io-0.8.7.tgz
npm http 304 https://registry.npmjs.org/async
npm http 200 https://registry.npmjs.org/connect/-/connect-1.7.3.tgz
npm http GET https://registry.npmjs.org/async/-/async-0.1.22.tgz
npm http 200 https://registry.npmjs.org/connect-redis/-/connect-redis-1.0.7.tgz
npm http 200 https://registry.npmjs.org/redis/-/redis-0.6.7.tgz
npm http 200 https://registry.npmjs.org/express/-/express-2.4.5.tgz
npm http 200 https://registry.npmjs.org/socket.io/-/socket.io-0.8.7.tgz
npm http 200 https://registry.npmjs.org/jade
npm http 200 https://registry.npmjs.org/async/-/async-0.1.22.tgz
npm http GET https://registry.npmjs.org/jade/-/jade-0.14.2.tgz
npm http 200 https://registry.npmjs.org/jade/-/jade-0.14.2.tgz

npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: express@2.4.5
npm ERR! Required: {"node":">= 0.4.1 < 0.5.0"}
npm ERR! Actual: {"npm":"1.1.4","node":"0.6.12"}
npm ERR!
npm ERR! System Linux 3.2.0-32-generic
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /opt/scrumblr
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! code ENOTSUP
npm ERR! message Unsupported
npm ERR! errno {}
npm http GET https://registry.npmjs.org/socket.io-client/0.8.7
npm http GET https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/mime
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /opt/scrumblr/npm-debug.log
npm not ok
root@ubuntu:/opt/scrumblr# vi package.json ^C
root@ubuntu:/opt/scrumblr# vi README.markdown
root@ubuntu:/opt/scrumblr# vi package.json
root@ubuntu:/opt/scrumblr# npm install
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/jade
npm http 304 https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/jade
npm http GET https://registry.npmjs.org/express/-/express-3.0.2.tgz
npm http 200 https://registry.npmjs.org/express/-/express-3.0.2.tgz
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.3
npm http GET https://registry.npmjs.org/cookie/0.0.4
npm http GET https://registry.npmjs.org/crc/0.2.0
npm http GET https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/cookie-signature/0.0.1
npm http GET https://registry.npmjs.org/send/0.1.0
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/connect/2.6.2
npm http GET https://registry.npmjs.org/commander/0.6.1
npm http 200 https://registry.npmjs.org/cookie/0.0.4
npm http 200 https://registry.npmjs.org/mkdirp/0.3.3
npm http GET https://registry.npmjs.org/cookie/-/cookie-0.0.4.tgz
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.3.tgz
npm http 200 https://registry.npmjs.org/crc/0.2.0
npm http 200 https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/crc/-/crc-0.2.0.tgz
npm http GET https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz
npm http 200 https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/methods/-/methods-0.0.1.tgz
npm http 200 https://registry.npmjs.org/cookie-signature/0.0.1
npm http GET https://registry.npmjs.org/cookie-signature/-/cookie-signature-0.0.1.tgz
npm http 200 https://registry.npmjs.org/cookie/-/cookie-0.0.4.tgz
npm http 200 https://registry.npmjs.org/send/0.1.0
npm http 200 https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/send/-/send-0.1.0.tgz
npm http GET https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/connect/2.6.2
npm http GET https://registry.npmjs.org/connect/-/connect-2.6.2.tgz
npm http 200 https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/commander/-/commander-0.6.1.tgz
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.3.tgz
npm http 200 https://registry.npmjs.org/crc/-/crc-0.2.0.tgz
npm http 200 https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz
npm http 200 https://registry.npmjs.org/methods/-/methods-0.0.1.tgz
npm http 200 https://registry.npmjs.org/cookie-signature/-/cookie-signature-0.0.1.tgz
npm http 200 https://registry.npmjs.org/send/-/send-0.1.0.tgz
npm http 200 https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/connect/-/connect-2.6.2.tgz
npm http 200 https://registry.npmjs.org/commander/-/commander-0.6.1.tgz
npm http GET https://registry.npmjs.org/mime/1.2.6
npm http GET https://registry.npmjs.org/qs/0.5.1
npm http GET https://registry.npmjs.org/formidable/1.0.11
npm http GET https://registry.npmjs.org/bytes/0.1.0
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http 200 https://registry.npmjs.org/pause/0.0.1
npm http GET https://registry.npmjs.org/pause/-/pause-0.0.1.tgz
npm http 200 https://registry.npmjs.org/mime/1.2.6
npm http GET https://registry.npmjs.org/mime/-/mime-1.2.6.tgz
npm http 200 https://registry.npmjs.org/qs/0.5.1
npm http GET https://registry.npmjs.org/qs/-/qs-0.5.1.tgz
npm http 200 https://registry.npmjs.org/formidable/1.0.11
npm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz
npm http 200 https://registry.npmjs.org/bytes/0.1.0
npm http GET https://registry.npmjs.org/bytes/-/bytes-0.1.0.tgz
npm http 200 https://registry.npmjs.org/pause/-/pause-0.0.1.tgz
npm http 200 https://registry.npmjs.org/mime/-/mime-1.2.6.tgz
npm http 200 https://registry.npmjs.org/qs/-/qs-0.5.1.tgz
npm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz
npm http 200 https://registry.npmjs.org/bytes/-/bytes-0.1.0.tgz
jade@0.14.2 ./node_modules/jade
express@3.0.2 ./node_modules/express
├── methods@0.0.1
├── fresh@0.1.0
├── cookie-signature@0.0.1
├── range-parser@0.0.4
├── cookie@0.0.4
├── crc@0.2.0
├── commander@0.6.1
├── debug@0.7.0
├── mkdirp@0.3.3
├── send@0.1.0 (mime@1.2.6)
└── connect@2.6.2


On va tenter de lancer Scrumblr

root@ubuntu:/opt/scrumblr# node server.js 80
The "sys" module is now called "util". It should have a similar interface.
Warning: express.createServer() is deprecated, express
applications no longer inherit from http.Server,
please use:

var express = require("express");
var app = express();

info - socket.io started

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'url' of undefined
at Function.handle (/opt/scrumblr/node_modules/express/node_modules/connect/lib/proto.js:104:18)
at Server.app (/opt/scrumblr/node_modules/express/node_modules/connect/lib/connect.js:66:31)
at Server.serverListening (/opt/scrumblr/node_modules/socket.io/node_modules/policyfile/lib/server.js:136:16)
at Server.g (events.js:156:14)
at Server.emit (events.js:64:17)
at Array.1 (net.js:753:10)
at EventEmitter._tickCallback (node.js:192:41)


Arghhh error !!!!!!
Bon j'ai passer un bon moment à me gratter la tête et j'ai réussi à trouver la solution.
Je vous l'offre sur un plateau.
Il semblerait que la version de express installé avec ubuntu 12.04 pose des problème.
On va installer express 2.5.9

root@ubuntu:/opt/scrumblr# npm uninstall express
root@ubuntu:/opt/scrumblr# npm install express@2.5.9

On tente de lancer Srumblr

root@ubuntu:/opt/scrumblr# node server.js 80
The "sys" module is now called "util". It should have a similar interface.
info - socket.io started
Youpi ca se lance.


Maintenant on va aussi faire un script pour lancer Scrumblr en tant que daemon au boot du serveur.

On va utiliser le script /opt/scrumblr/forever.sh
Pour cela il faut install le module forever avec npm


root@ubuntu:/opt/scrumblr# npm install forever -g

root@ubuntu:/opt/scrumblr# vi /etc/init.d/scrumblr

#!/bin/sh

### BEGIN INIT INFO
# Provides: Scrumblr
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts Scrumblr
# Description: starts Scrumblr lite using start-stop-daemon
### END INIT INFO

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/scrumblr.log"
EPLITE_BIN="/opt/scrumblr/forever.sh"
USER="scrumblr"
GROUP="scrumblr"
DESC="scrumblr"
NAME="scrumblr"
PORT="80"

set -e

. /lib/lsb/init-functions

start() {
echo "Starting $DESC... "
$EPLITE_BIN
echo "done"
}


stop() {
echo "Stopping $DESC... "
PIDS=$(pgrep node)
for i in $PIDS;
do
kill -9 $i
done
echo "done"
}

status() {
PIDS=$(pgrep node)
if [ -z "$PID" ]
then
echo "$NAME is running"
else
echo "$NAME is not running"
fi
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart


On le rend executable.
root@ubuntults:/var/log# chmod +x /etc/init.d/scrumblr

On active le script au démmarage:

 root@ubuntu:/opt/scrumblr# update-rc.d scrumblr defaults
Adding system startup for /etc/init.d/scrumblr ...
/etc/rc0.d/K20scrumblr -> ../init.d/scrumblr
/etc/rc1.d/K20scrumblr -> ../init.d/scrumblr
/etc/rc6.d/K20scrumblr -> ../init.d/scrumblr
/etc/rc2.d/S20scrumblr -> ../init.d/scrumblr
/etc/rc3.d/S20scrumblr -> ../init.d/scrumblr
/etc/rc4.d/S20scrumblr -> ../init.d/scrumblr
/etc/rc5.d/S20scrumblr -> ../init.d/scrumblr


root@ubuntults:/var/log# /etc/init.d/scrumblr start

Notre scrumblr est bien lancé

root@ubuntu:/opt/scrumblr# ps aux | grep node
root 3541 0.0 2.6 721084 13412 ? Ssl 12:30 0:00 node /usr/local/bin/forever start -o out.log -e err.log server.js 80
root 3542 0.2 3.7 782720 18608 ? Sl 12:30 0:00 node /opt/scrumblr/server.js 80

L'interface:
Notre node écoute sur le port 80

on arrive donc sur notre board à partir de : http://votre_serveur

scrumblr 1
Ho que c'est joli par contre c'est en Anglais.
Moi j'aime mieux le français.

Il suffit de modifier le fichier: /opt/scrumblr/views/home.jade

Et hop :)

Scrumblr 2

La belle interface, ou vous pouvez créer des notes, des sections, et même coller des gommettes :)

scrumblr3
13 novembre 2012 97 commentaires

#Gnu/Linux, Planet Libre

Installation d'une solution de collaboration: Etherpad Lite

etherpad
Installation d'une solution de collaboration Etherpad Lite

J'ai eut besoin récemment pour les associations pour lesquelles je suis un peu sysadmin, de mettre en place une solution de collaboration texte.
Bien sur il existe les Google Docs et autres mais je voulais un outil simple et hebergé par mes serveurs.
J'ai un peu cherché et je suis tombé sur Etherpad !





EtherPad est un éditeur de texte collaboratif en temps réel. Il permet par défaut à un maximum de seize personnes de partager un texte en cours d'élaboration. Les contributions de chacun apparaissent immédiatement sur l'écran de tous les participants et sont signalées par des couleurs différentes. Une fenêtre de messagerie instantanée est également disponible.

Le système ne requiert aucune installation, ni aucune inscription, il suffit d'avoir une connexion internet et un navigateur web. EtherPad est écrit en JavaScript.

Etherpad était un éditeur (de texte) en ligne permettant de travailler à plusieurs sur un document. Le code fut ouvert par Google quand ils en firent l'acquisition pour l'intégrer à Google Wave (il me semble, ou alors c'était dans Google Docs), dans la foulée une fondation fut créée pour continuer à le faire vivre, et des pads fleurirent un peu partout, malgré la gourmandise du logiciel (les mauvaises langues, dont je ne suis pas, attribueront cette lourdeur au fait que le logiciel ait été écrit en Scala, et donc dépende de Java). Mais il était hors de portée des serveurs dédiés virtuels (VPS) pas chers, et autres mini serveurs.

C'est là qu'entre en scène Etherpad Lite, nettement moins gourmand, il se base sur Node.js, a moins de dépendances ésotériques que son ancêtre, et d'après les développeurs, là où un Etherpad occupait 257 Mo de RAM juste après son démarrage, Etherpad
Lite n'en occupe que 16 Mo. Il est disponible sous licence Apache 2.0. (source :http://linuxfr.org/news/etherpad-lite)


Etherpad vs Etherpad Lite

  Etherpad Etherpad Lite
Size of the folder (without git history) 30 MB 1.5 MB
Languages used server side Javascript (Rhino), Java, Scala Javascript (node.js)
Lines of server side Javascript code ~101k ~9k
RAM Usage immediately after start 257 MB (grows to ~1GB) 16 MB (grows to ~30MB)



Plateforme Materielle :

Comme d'habitude, j'ai monté mon prototype sur ma plateforme de virtualisation:

Dedibox Pro HP
Plateforme logicielle hyperviseur:
  • Dom0 Opensuse 12.1 X86_64 Xen 4.1
Plateforme Virtuelle:

  • DomU Xen Ubuntu 10.04 X86_64 Paravirtualisé
  • 2 vcpus 
  • 512 Mo de Ram
  • HDD 16GB


Installation:

Pour commencer j'ai mis à jour totalement mon DomU ubuntu 10.04; mon template avait quelques maj de retard :)

  • Mise à niveau du DomU
root@ubuntults:/# apt-get update; apt-get upgrade
root@ubuntults:/# apt-get install linux-headers-server linux-image-server linux-server
root@ubuntults:/# reboot

  • Installation des prérequis
root@antony-linux:/home/antony# apt-get install gzip git-core curl python libssl-dev pkg-config build-essential

  • Installation de node.js
On télécharge la dernière version de node.js et on la compile
    root@antony-linux:/home/antony# wget http://nodejs.org/dist/v0.6.15/node-v0.6.15.tar.gz
    root@antony-linux:/home/antony# tar xvfz node-v0.6.15.tar.gz
    root@antony-linux:/home/antony/# cd node-v0.6.15
    root@antony-linux:/home/antony/#./configure; make; make install

  • Installation de Etherpad lite 
On utilse git pour récupérer la dernière version.
root@antony-linux:/home/antony# git clone 'git://github.com/Pita/etherpad-lite.git'
Initialized empty Git repository in /home/antony/etherpad-lite/.git/
remote: Counting objects: 8065, done.
remote: Compressing objects: 100% (2632/2632), done.
remote: Total 8065 (delta 5738), reused 7590 (delta 5318)
Receiving objects: 100% (8065/8065), 2.76 MiB | 626 KiB/s, done.
Resolving deltas: 100% (5738/5738), done.


Je déplace le tout ce /opt

root@antony-linux:/home/antony# mv etherpad-lite /opt/etherpad

On installe les dépendances
root@ubuntults:/opt/etherpad# /opt/etherpad/bin/installDeps.sh

A partir d'ici on peut déjà lancer Etherpad.

root@ubuntults:/opt/etherpad# /opt/etherpad/bin/run.sh 
You shouldn't start Etherpad-Lite as root!
Please type 'Etherpad Lite rocks my socks' if you still want to start it as root
Etherpad Lite rocks my socks
Ensure that all dependencies are up to date...
Ensure jQuery is downloaded and up to date...
Ensure prefixfree is downloaded and up to date...
Clear minfified cache...
ensure custom css/js files are created...
start...
[2012-04-20 17:01:09.999] [INFO] console - Your Etherpad Lite git version is 309e3b0
[2012-04-20 17:01:10.002] [INFO] console - Report bugs at https://github.com/Pita/etherpad-lite/issues
[2012-04-20 17:01:10.124] [INFO] console - Server is listening at 0.0.0.0:9001
[2012-04-20 17:01:10.125] [INFO] console -    info  - 'socket.io started'


Accès à l'interface Web:



Si tout est bien installé démarré, on peut acceder à l'interface Web de etherpard sur le port 9001



http://votre_ip:9001


Bon on à installer Etherpad Lite et on l'a lancé.
C'est bien joli, mais déjà on le lance en root ce qui n'est pas jojo et on est obligé de lancer le script à la main...
C'est pas très optimisé...


Optimisations :
Afin de pouvoir bénéficier des fonctions d'import il faut installer abiword
root@ubuntults:~# apt-get install abiword

Il faut modifier le settings.json dans le dossier etherpad pour que ce soit pris en compte
root@ubuntults:~# vi /opt/etherpad/settings.json

///////
   Abiword is needed to enable the import/export of pads*/
 "abiword" : "/usr/bin/abiword",
//////

Afin que se soit utilisable, nous allons créer un script qui permettera de lancer Etherpad en daemon et surtout pas en root....

On crée un user Etherpad et on donne les droits adéquats.
root@ubuntults:~# useradd etherpad

root@ubuntults:~# chown -R etherpad /opt/etherpad


On crée maintenant un script d'init afin de pouvoir lancer Etherpad en tant que daemon
Ce script nous permet de lancer etherpad en tant que etherpad et aussi de pouvoir la lancer au demmarage.

#!/bin/sh

### BEGIN INIT INFO
# Provides: etherpad-lite
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts etherpad lite
# Description: starts etherpad lite using start-stop-daemon
### END INIT INFO

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/etherpad.log"
EPLITE_DIR="/opt/etherpad"
EPLITE_BIN="bin/run.sh"
USER="etherpad"
GROUP="etherpad"
DESC="Etherpad"
NAME="etherpad"

set -e

. /lib/lsb/init-functions

start() {
echo "Starting $DESC... "

start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
echo "done"
}

#We need this function to ensure the whole process tree will be killed
killtree() {
local _pid=$1
local _sig=${2-TERM}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child} ${_sig}
done
kill -${_sig} ${_pid}
}

stop() {
echo "Stopping $DESC... "
while test -d /proc/$(cat /var/run/$NAME.pid); do
killtree $(cat /var/run/$NAME.pid) 15
sleep 0.5
done
rm /var/run/$NAME.pid
echo "done"
}

status() {
status_of_proc -p /var/run/$NAME.pid "" "etherpad" && exit 0 || exit $?
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $NAME {start|stop|restart|status}" >&2
exit 1
;;
esac

exit 0

On le rend executable.
root@ubuntults:/var/log# chmod +x /etc/init.d/etherpad

On active le script au démmarage:

root@ubuntults:/var/log# update-rc.d etherpad defaults
 Adding system startup for /etc/init.d/etherpad ...
   /etc/rc0.d/K20etherpad -> ../init.d/etherpad
  /etc/rc1.d/K20etherpad -> ../init.d/etherpad
   /etc/rc6.d/K20etherpad -> ../init.d/etherpad
   /etc/rc2.d/S20etherpad -> ../init.d/etherpad
  /etc/rc3.d/S20etherpad -> ../init.d/etherpad
   /etc/rc4.d/S20etherpad -> ../init.d/etherpad
   /etc/rc5.d/S20etherpad -> ../init.d/etherpad

root@ubuntults:/var/log# /etc/init.d/etherpad start

Notre etherpad est bien lancé

root@ubuntults:/var/log# ps aux | grep etherpad
etherpad 15021  0.0  0.0   4096   628 ?        S    21:39   0:00 /bin/sh /opt/etherpad/bin/run.sh /var/log/etherpad.log
etherpad 15049  1.5  1.2 717752 25192 ?        Sl   21:39   0:09 node server.js /var/log/etherpad.log

L'interface:






  • La fonction Chat




  • Les options


  • La fonction d'import




  • La fonction partage avec QRcode !

  • La fonction replay







Etherpad est un outil simple installer, léger,  et agréable à utiliser.
Bien sur il n'a pas toutes les fonctionnalités de Google Docs ou autres, mais il suffit bien pour la majorité des usages
Surtout le plus important c'est qu'il est installé sur vos serveurs.


Optimisations :

Je repends cet article pour améliorer un peu le système.

De base, les pads dans etherpad-lite sont stockés dans un fichier appelé dirtydb
Il porte bien son nom puisque tout est écrit à la suite en dur, sans aucune optimisations...
Ca va bien pour tester, mais si le nombre de pads devient conséquents ca va vite devenir problématique...

C'est pourquoi j'ai préféré utiliser mysql pour stocker les données...


root@ubuntults#mysql -u root -p
create database `etherpad`;
grant all privileges on `etherpad`.* to 'etherpad'@'localhost' identified by 'etherpad';
Relancer etherpad-lite afin qu'il peuple la base de donnée.

root@ubuntults#ALTER DATABASE `etherpad` CHARACTER SET utf8 COLLATE utf8_bin;
USE `etherpad`;
ALTER TABLE `store` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
Modifier votre settings.json pour utiliser mysql

 // An Example of MySQL Configuration
"dbType" : "mysql",
"dbSettings" : {
"user" : "etherpad",
"host" : "localhost",
"password": "etherpad",
"database": "etherpad"
},

Relancer Etherpad et voilà il utilise mysql.



Interface Web :

L'interface web de base de Etherpad-lite est très basique.
Je recherche activement une interface complète qui perméttrait d'utiliser toutes les fonctions de etherpad-lite

En effet Etherpad-lite dispose dune api bien fournie et on peut aller très loin...

En attendant un developpeur motivé, j'ai du faire 2 ou 3 ligne de php pour avoir quelquechose d'utilisable...
Je ne suis pas du tout developpeur... alors j'ai un peu galéré..

L'interface de base permet juste de creer un pad, ce qui est l'essentiel, mais si on veut modifier un pad déjà crée il fallait connaitre son nom...
ce qui n'est pas très pratique...
Je voulais au moins pouvoir visualiser le nom des pad déjà crées.

Je suis arrivé en bricolant un peu de html, jquery, php à avoir ça...



Je ne mettrai pas le code sur le billet.
Si vous etes interessé par cette petite page web contactez moi.

21 avril 2012 13 commentaires