Enable the play framework application to start automatically in ubuntu

Source: Internet
Author: User

Enable the play framework application to start automatically in ubuntu

Note: Because the uploaded file must have a suffix, The. sh suffix is added, and the suffix is removed after downloading.

Note ### begin init info and ### end init info cannot be deleted, not just comments. They are used for identification during startup by the system.

Replace the myapp and java home directories in the script with your application.

Rm *****. The pid statement should be deleted to prevent the illegal shutdown of play. The pid file is left, And the start command cannot be started normally.

The touch statement can be deleted to test whether execution is performed.

----------------------------------------------------------------------------------

Update-rc.d-f myapp remove

Is to delete all symbolic links of/etc/init. d/myapp. After deletion, it will not start automatically.

Update-rc.d myapp defaults 98 8.

Set the startup sequence of the myapp STARTUP script to 98. The shutdown sequence (the sequence when the ubuntu system is disabled) to 8.

Values can be modified based on different systems. View/etc/rc0.d to/etc/rc6.d

Check the SnnXXXX and KnnXXX files and arrange the startup sequence properly. The greater the order value, the closer it is to the back.

In my system, the mysql startup sequence is 85, the lighttpd startup sequence is 91, and the shutdown sequence is 09,

Make sure that play is started after mysql and lighttpd and disabled before lighttpd,

So set 98 8

Execute this script, restart, and play will be automatically started.

To test whether the myapp script is available,

Run/etc/init. d/myapp start

/Etc/init. d/myapp restart

/Etc/init. d/myapp stop

Myapp. sh:

Copy to ClipboardReference: [www.bkjia.com] #! /Bin/sh

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: myapp
# Required-Start: $ local_fs $ network $ remote_fs
# Required-Stop: $ local_fs $ network $ remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop myappservice
# Description: myappservice is myapp server
### END INIT INFO

JAVA_HOME =/myappsys/jdk/jdk1.6.0 _ 24
JRE_HOME =/myappsys/jdk/jdk1.6.0 _ 24/jre
CLASSPATH = ".: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH"
PATH = "$ JAVA_HOME/bin: $ JRE_HOME/bin:/myappsys/mysql/bin: $ PATH"

./Lib/lsb/init-functions

Case "$1" in
Start)
Rm/myappsys/myappservice/myapp/server. pid
/Myappsys/play-1.1.1/play start/myappsys/myappservice/myapp
Touch/myappsys/play/myapp_start_2222222
;;
Stop)
/Myappsys/play-1.1.1/play stop/myappsys/myappservice/myapp
Rm/myappsys/myappservice/myapp/server. pid
Touch/myappsys/play/myapp_stop_2222222
;;
Restart | force-reload)
/Myappsys/play-1.1.1/play stop/myappsys/myappservice/myapp
Rm/myappsys/myappservice/myapp/server. pid
/Myappsys/play-1.1.1/play start/myappsys/myappservice/myapp
Touch/myappsys/play/myapp_restart_22222
;;
*)
Echo "Usage:/etc/init. d/myapp {start | stop | restart | force-reload }"
Exit 1
;;
Esac

Exit 0

Install_myapp.sh:

Copy to ClipboardReference: [www.bkjia.com] update-rc.d-f myapp remove

Cp myapp/etc/init. d/
Chmod + x/etc/init. d/myapp
Update-rc.d myapp defaults 98 8.

Sleep 100

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.