2013-03-27 28 views
7

Imparo meteorjs e ho un piccolo VPS remoto.Come eseguire mete all'avvio sul server Ubuntu

voglio:

  1. Set auto tirando dal repository git mio progetto meteora.
  2. Inserire lo script in avvio automatico che esegue il mio progetto meteor come servizio.

Per esempio

meteor run -p 80 -- production 

Il mio server è Ubuntu 12.04

risposta

13

Si dovrebbe usare modo Ubuntu, che è Upstart:

http://upstart.ubuntu.com/ http://manpages.ubuntu.com/manpages/lucid/man5/init.5.html

Come definire lavoro daemon :

http://newcome.wordpress.com/2012/02/26/running-programs-as-linux-daemons-using-upstart/

Speranza che aiuta :)

Il file upstart sarebbe più o meno:

# meteorjs - meteorjs job file 

description "MeteorJS" 
author "Igor S" 

# When to start the service 
start on runlevel [2345] 

# When to stop the service 
stop on runlevel [016] 

# Automatically restart process if crashed 
respawn 

# Essentially lets upstart know the process will detach itself to the background 
expect fork 

# Run before process 
pre-start script 
     cd PATH_TO_METEOR_APP 
     echo "" 
end script 

# Start the process 
exec meteor run -p 80 --help -- production 
+0

come eseguire meteorite all'avvio con Mac OSX? – crapthings

+0

Thx. Il suo lavoro va bene –

+2

Che cos'è 'exec myprocess'? – gor

1

Questo è il mio file meteorjs.conf - funziona bene. Avevo già descritto tutti i problemi, ma questa variante li risolve. Speranza che aiuta qualcuno :)

Tutti EXPORT variabili che ho ricevuto da printenv

# meteorjs - meteorjs job file 

description "MeteorJS" 
author "Alex Babichev" 

# When to start the service 
start on runlevel [2345] 

# When to stop the service 
stop on runlevel [016] 

# Automatically restart process if crashed 
respawn 

# Essentially lets upstart know the process will detach itself to the background 
expect fork 

chdir /home/dev/www/test 

script 

export MONGO_URL=mongodb://localhost:27017/meteor 
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
export PWD=/home/sputnik 
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript 
export HOME=/home/sputnik 

echo "---- start ----" 
cd /home/dev/www/test 
exec mrt 

end script 
+0

Non ha superato l'URL di mongo e ha modificato l'ultima riga per: 'exec meteor -p dominio.com : 8080' doveva anche 'chmod + x/etc/init/meteorjs.conf' e funziona benissimo :) Thx – Guidouil

+0

' env HOME =/home/sputnik' se non ti piace lo script nel tuo script. –

4

Ecco quello che faccio:

description "meteor app server" 
start on runlevel [2345] 
stop on runlevel [06] 
respawn 
respawn limit 10 5 
pre-start script 
    set -e 
    rm -f /path/to/your/app/.meteor/local/db/mongod.lock 
end script 
exec /bin/su - ec2-user -c '/path/to/your/app/meteor_server.sh' 
post-stop script 
    pkill -f meteor 
end script 

Lo script meteor_server.sh contiene:

cd /path/to/your/app/; meteor run -p 3000 --production 

Assicurati di chmod +x lo script meteor_server.sh e modificare il percorso della tua app nelle 3 posizioni. Lo script uccide anche tutte le attività di meteor quando viene arrestato, quindi funziona per l'esecuzione di una singola app meteorica solo sul tuo server. Ho ottenuto un'app meteor per funzionare velocemente in questo modo usando nginx ma il nodo sembra consumare molta memoria.

Problemi correlati