Los servidores Comet – APE

En este articulo, voy a detallar la instalacion y uso de uno de los servidores Comet que estuvimos viendo en un comentario anterior. Aunque vimos que hay una gran variedad, lo cierto es que gratuitos y que sea mas o menos facil ponerlos en marcha, ya no hay tantos, en este caso, hemos escogido uno realizado en JavaScript que puede correr conjuntamente con nuestro servidor Apache, podeis encontrarlo, y descargarlo en ape.

Comentaros que para instalarlo, debereis tener pleno acceso a la maquina, por lo que en entornos de hosting compartido, no sera facil, a menos que convenzais a vuestro proveedor de las bondades del producto; pero si podeis instalarlo…:Veamos como hacerlo en Centos:

Descarguemos los ejecutables de la web del proyecto ajax push engine.

Con esto conseguiremos un fichero tar que deberemos expandir

[email protected] [~]# tar -xzvf APE-Project_1.0.tar.gz

esto nos generara un directorio APE-Project_1.0 y cambiaremos a el con

[email protected] [~]# cd APE-Project_1.0
[email protected] [~/APE-Project_1.0]# cd ape-server
[email protected] [~/APE-Project_1.0/ape-server]#

en este directorio, encontramos los instalables como RPM, debian,… tanto para 32 bits como para 64, y los fuentes. Tambien nos encontramos untar para instalacion en cualquier distribucion, sin embargo, ya que en Centos disponemos del instalador de rpm, nos decidimos por esa opcion

[email protected] [~/APE-Project_1.0/ape-server]# rpm -Uvh APE_Server-1.0.i386.rpm

Con esto finalizaremos la instalacion del servidor.

A continuacion, crearemos el script para hacer que la aplicacion arranque cada vez que se inicie el ordenador; para ello, creamos un fichero en el directorio /etc/init.d con el nombre de aped

#! /bin/sh
# /etc/init.d/aped
#
# chkconfig: 2345 85 15
# description: APE Daemon
# processname: APE Daemon

#
# Install the service with chkconfig --add aped
# 

# Define where ape is installed.
# The trailing slash is required ( Example : /my/path/bin/ )
APE_DIRECTORY=/etc/ape/

# Define the PID File
PIDFILE=/var/run/aped.pid

# Source function library.
. /etc/init.d/functions

DAEMON="/usr/bin/aped --cfg ${APE_DIRECTORY}ape.conf > /dev/null"

start() {

        echo -n "Starting APE... "

        cd $APE_DIRECTORY;
        daemon $DAEMON
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/aped
        return $RETVAL
}

stop() {
        echo "Stopping APE..."
        kill `cat /var/run/aped.pid`
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/aped
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage:  {start|stop|restart}"
        exit 1
        ;;
esac
exit $RETVAL

Modificamos los permisos para hacerlo ejecutable, lo añadimos a la lista de servicios, y por ultimo  utilizamos /usr/sbin/ntsysv para activar o desactivar el servicio al arramque

[email protected] [~/APE-Project_1.0/ape-server]# chmod a=x /etc/init.d/aped
[email protected] [~/APE-Project_1.0/ape-server]# chkconfig --add aped
[email protected] [~/APE-Project_1.0/ape-server]# /usr/sbin/ntsysv

Siguiente paso: modificar el fichero de configuracion para indicar que deseamos que funcione como demonio. Esto lo hacemos abriendo el fichero /etc/ape/ape.conf modificandlo la linea de daemon para dejarla como “daemon = yes”; ahora ya estamos a punto para arrancar nuestro servidor con

[email protected] [~/APE-Project_1.0/ape-server]# /etc/init.d/aped start
Starting APE...                                            [  OK  ]
[email protected] [~/APE-Project_1.0/ape-server]#
Nuestro siguiente paso es instalar las aplicaciones demo…

Acerca de Miguel Garcia

Programador, Desarrollador web, Formador en distintas areas de informatica y director de equipos multidisciplinares.
Esta entrada fue publicada en Servidores Comet. Guarda el enlace permanente.

10 respuestas a Los servidores Comet – APE

  1. Pablo dijo:

    He visto el tutoriql esta hecho en linux de verdad me interesa en windows tendras algun tutorial?

    • admin dijo:

      Realmente no me lo he planteado, y si te das cuenta, los servidores Comet no son la solucion tampoco; siguen consumiendo ancho de banda, aunque menos. Y las estructuras utilizadas en el cliente son demasiado retorcidas. Sigo buscando otras soluciones.

  2. Damian dijo:

    Hola, cuando ejecuto la linea

    /usr/sbin/ntsysv
    me dice que el fichero o el directorio no existe, y de verdad que no existe no se encuentra alli el ntsysv, todas los pasos anteriores los hice bien, yo cree mi documento aped y verifique que se encontrara en /etc/init.d/aped donde aped es el documento. que estare haciendo mal??
    Espero que me respondas rapidamente, y me gustaria por favor si tienes un correo donde te pueda escribir, seria de mucha ayuda.
    Muchas Gracias.

  3. Damian dijo:

    hay algo extrano que note: cuando ejecuto lo siguiente

    [email protected]:/etc/init.d# chkconfig –add aped
    insserv: warning: script ‘K01aped’ missing LSB tags and overrides
    insserv: warning: script ‘K01acpi-support’ missing LSB tags and overrides
    insserv: warning: script ‘aped’ missing LSB tags and overrides
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘gdm’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `gdm’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `gdm’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘console-setup’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `console-setup’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `console-setup’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘hwclock’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hwclock’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `hwclock’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘plymouth-stop’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-stop’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `plymouth-stop’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘udev’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udev’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `udev’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘procps’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `procps’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `procps’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘alsa-mixer-save’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `alsa-mixer-save’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `alsa-mixer-save’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘module-init-tools’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `module-init-tools’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `module-init-tools’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘avahi-daemon’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `avahi-daemon’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `avahi-daemon’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘dbus’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `dbus’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `dbus’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘acpid’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `acpid’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `acpid’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘network-manager’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-manager’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `network-manager’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘network-interface-security’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-interface-security’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `network-interface-security’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘plymouth-log’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-log’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `plymouth-log’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘udev-finish’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udev-finish’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `udev-finish’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘plymouth-splash’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth-splash’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `plymouth-splash’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘cron’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cron’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `cron’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘hwclock-save’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hwclock-save’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `hwclock-save’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘network-interface’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `network-interface’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `network-interface’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘ufw’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `ufw’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `ufw’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘anacron’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `anacron’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `anacron’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘dmesg’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `dmesg’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `dmesg’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘udevmonitor’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udevmonitor’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `udevmonitor’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘udevtrigger’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `udevtrigger’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `udevtrigger’
    insserv: warning: script ‘acpi-support’ missing LSB tags and overrides
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘screen-cleanup’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `screen-cleanup’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘smbd’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `smbd’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `smbd’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘rsyslog’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `rsyslog’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `rsyslog’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘atd’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `atd’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `atd’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘irqbalance’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `irqbalance’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `irqbalance’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘plymouth’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `plymouth’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `plymouth’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘cups’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cups’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `cups’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘failsafe-x’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `failsafe-x’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `failsafe-x’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘hostname’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `hostname’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `hostname’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘nmbd’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nmbd’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `nmbd’
    The script you are attempting to invoke has been converted to an Upstart
    job, but lsb-header is not supported for Upstart jobs.
    insserv: warning: script ‘apport’ missing LSB tags and overrides
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `apport’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `apport’
    aped 0:off 1:off 2:on 3:on 4:on 5:on 6:off

  4. Damian dijo:

    no se mucho de ubuntu, pero lo que hice fue crear un documento y pegarle el script que colocaste alli, yo no se si eso deberia llevar un tipo de extension particular, yo solo tome ese documento aped y lo traslade al directorio de /etc/init.d

    Espero que me puedas ayudar por favor!!!

    • migarcia dijo:

      Disculpa, ten en cuenta que el tutorial esta hecho para Centos, en Ubuntu tienes que encontrar las ordenes; concretamente para iniciar y parar servicios lo puedes hacer con /etc/init.d/aped [start/stop], asi como para añadirlo a los runlevels puedes utilizar el comando update.rc

      Dejando aparte la ayuda que pueda prestarte… que para eso estamos, para cambiar de distribucion y adaptarlo busca en google para saber que hace un comando en Centos, y luego busca el equivalente en Ubuntu… ya se que es duro, pero se aprende mucho

  5. damian dijo:

    Oye, ya me di cuenta, disculpa lo que sucede es que no se mucho de linux, pero ya logre levantar el Servidor APE en ubuntu, por otro lado como no tengo mucha experiencia en esto, quisiera preguntarte a ver, como haces para ver los proyectos es decir por ejemplo un archivo .php, porque yo busque una carpeta llamada www pero no la encontre supuestamente deberia estar en /var/www y alli no aparece nada, asi que me atrevi a crearla y colocar mis proyectos alli pero no funciono, en Centos capaz es lo mismo , en donde colocas los proyectos para verlo en localhost? Gracias por tu ayuda, y disculpa las molestias
    pd// yo solo instale el server APE pero he visto en otros blog que instalan Apache, pero no lo encuentro logico, ya que por lo que entiendo el server APE ya es un servidor para que levantar dos servidores?

    • migarcia dijo:

      El servidor APE es auxiliar; tu has de trabajar con Apache, por ejemplo, de modo normal; tus paginas las ha de servir Apache, y el servidor APE se utiliza desde las paginas, por medio de Javascript
      El montaje de APE es bastante rudimentario, se podria utilizar como servidor principal, supongo, pero se tendria que revisar alguna cosa; su mision es la de mantener una conexion viva…Esto es que puedas iniciar el dialogo desde el servidor, que es lo contrario a lo que haces habitualmente…

  6. damian dijo:

    es necesario levantar apache, para que funcione el server APE? sino es necesario donde coloco mis proyectos para verlos en localhost:6969? localhost:6969 es donde levante mi servidor APE

  7. Alex dijo:

    Starting APE… /bin/bash: /usr/bin/aped: No such file or directory
    [FAILED]

    🙁

Deja un comentario