How to allow the diaspora to start when the server boots

To start the diaspora, you must run the following command:

cd / home / diaspora

./script/Sever

My server (Ubuntu 11.10) - daily restart. I need to configure the server (Ubuntu 11.10) so that the diaspora server starts every time my server is running. How to do it?

I tried:

Log in as the user who runs the diaspora as, open the crontab editor (crontab -e), scroll to the end and enter:

@reboot cd / home / diaspora; ./ script / Sever

then save, but it still does not start after loading my server.

And, if crontab -e cannot do this, is it possible to write an init script for this? If the init script can do this, how to write a script to do this?

+4
source share
1 answer

First you need to create an init script:

# This is the init script for starting up the # Diaspora # # chkconfig: 345 91 10 # description: Starts and stops the Diaspora daemon. # PROC_NAME=Diaspora DIASPORA_HOME=/home/diaspora # Change the user to whichever user you need RUN_AS_USER=diaspora startup="cd $DIASPORA_HOME; ./script/server" # Replace by stop/shutdown command #shutdown="$DIASPORA_HOME/script/server" start(){ echo -n $"Starting $PROC_NAME service: " su -l $RUN_AS_USER -c "$startup" RETVAL=$? echo } stop(){ echo -n $"Stoping $PROC_NAME service: " # Uncomment here to allow stop # su -l $RUN_AS_USER -c "$shutdown" RETVAL=$? echo } restart(){ stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac exit 0 

Then make an executable file:

 sudo chmod +x /etc/init.d/diaspora 

Then you need to tell Ubuntu to start / stop, usually using the default runlevels (assuming you saved the previous script in /etc/init.d/diaspora):

 sudo update-rc.d diaspora defaults 

Then try:

 sudo service diaspora start 

or

 sudo /etc/init.d/diaspora start 

If the diaspora begins, then you are good to go. Otherwise, the script may need to be adjusted.

+5
source

Source: https://habr.com/ru/post/1394519/


All Articles