"init script" Code Answer's

You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "init script" answered properly. Developers are finding an appropriate answer about init script related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like init script. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on init script. 

init script

By MagooMagoo on Apr 20, 2021
#!/bin/sh
#
# init script for a Java application
#

# Check the application status
#
# This function checks if the application is running
check_status() {

  # Running ps with some arguments to check if the PID exists
  # -C : specifies the command name
  # -o : determines how columns must be displayed
  # h : hides the data header
  s=`ps -C 'java -jar /path/to/application.jar' -o pid h`

  # If somethig was returned by the ps command, this function returns the PID
  if [ $s ] ; then
    return $s
  fi

  # In any another case, return 0
  return 0

}

# Starts the application
start() {

  # At first checks if the application is already started calling the check_status
  # function
  check_status

  # $? is a special variable that hold the "exit status of the most recently executed
  # foreground pipeline"
  pid=$?

  if [ $pid -ne 0 ] ; then
    echo "The application is already started"
    exit 1
  fi

  # If the application isn't running, starts it
  echo -n "Starting application: "

  # Redirects default and error output to a log file
  java -jar /path/to/application.jar >> /path/to/logfile 2>&1 &
  echo "OK"
}

# Stops the application
stop() {

  # Like as the start function, checks the application status
  check_status

  pid=$?

  if [ $pid -eq 0 ] ; then
    echo "Application is already stopped"
    exit 1
  fi

  # Kills the application process
  echo -n "Stopping application: "
  kill -9 $pid &
  echo "OK"
}

# Show the application status
status() {

  # The check_status function, again...
  check_status

  # If the PID was returned means the application is running
  if [ $? -ne 0 ] ; then
    echo "Application is started"
  else
    echo "Application is stopped"
  fi

}

# Main logic, a simple case to call functions
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  restart|reload)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|reload|status}"
    exit 1
esac

exit 0

Source: gustavostraube.wordpress.com

Add Comment

0

All those coders who are working on the Whatever based application and are stuck on init script can get a collection of related answers to their query. Programmers need to enter their query on init script related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about init script for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of init script while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "init script". Visit this developer's friendly online web community, CodeProZone, and get your queries like init script resolved professionally and stay updated to the latest Whatever updates. 

Whatever answers related to "init script"

View All Whatever queries

Whatever queries related to "init script"

cloudbase-init windows 10 cloudbase-init-unattend.conf init script rasa init rasa : The term 'rasa' is not recognized Unable to init server: Could not connect: Connection refused (eog:22): Gtk-WARNING **: 21:54:46.367: cannot open display: unity scrollrect init pos init obserable with values Unable to init server: Could not connect: Connection refused (gedit:7575): Gtk-WARNING **: 10:17:11.806: cannot open display: init tracker engine = pyttsx3.init('sapi5') voices = engine.getProperty('voices') engine.setProperty('voice', voices[1].id) rasa init ModuleNotFoundError: No module named 'telebot.types' init(forReading: URL) can't use is_home query on init hook what is Razor Script disable script in unity godot first person controller script button script visual studio 2019 google script last row sprite unity script how to know username apps script nmap -Pn --script vuln ipaddr minecraft server start batch script Refused to execute inline script because it violates the following Content Security Policy directive How to make a script that spawns parts what to do if script fails Smooth Camera script roblox studiio Head/Waist follow Mouse/Camera script js jquery include external script terraform script to create s3 bucket how to write a script to render in iframe app script for google forms to email app hypertext preprocessor script Account age blacklist script for roblox script dir bash travis allow_failures script Difference between Test case and Test script? load test script locust roblox studio change size script How to make a cash giving script execute a menu command from script unity how to make a death animation script Brick spawner script for roblox studio find duplicates apps script html5 script external How to make a bubble chat script part spawner script for roblox studio dontdestroyonload script zsh print each line of script btn script t rex how to call a void from difrent script unity fps camera rotation script obs studio use script npm run build npm ERR! Missing script: "build" for firebase unity change button onclick in script test case vs test script rest assured script how to get the script of fontawesome how to make a creator joined script TypeError: Cannot read property 'RecId' of undefined app script script generate tracking number ups by post how to make a 24 minute day night script npm ERR! missing script: build:dev bash script cheat sheet run python script in kubernetes how to make a owner joined script quizlet In converting an entrepreneurial business script into an enterprise value chain, the financing process of the value chain is usually made up of two different scenes what will you do if test script fails long query running script teste google script photoshop script create prompt How to amke a Gamepass script in roblox studio 2020 half life bhop script nickaname and tag unity and pun2 script bs4 get text from script tag how to run a script in crontab every day mikrotik script check ip public activate pane apple script test scenario, test case and test script boot up batch script pop cat script how to make a player join / left script windows batch script to run application in background can we script test case without object repository photoshop script open file dialog how to save script in another file How to make a rain script photoshop script confirmation prompt bash script in array slow query script app script comparison existing data hack discord script script and style for admin menu How to amke a death animation script keynote Present Keynote slideshow: display script of similar information that only you can see: photoshop script: save as jpg bash script exec blocks Slow walk script dockerfile chmod: changing permissions of './script.sh': Operation not permitted unity 2d platformer movement script rigidbody bash script speichern from speed test in influxdb batch script delete files older than 30 days exemples de script iptables total time taken by script how to send mail in pdf format in netsuite using script roblox kick player script script deferred how to get the player character roblox script script to get pem expiration date unity player move script terraform script to launch aws instance launch regex to filter login script injection npm run script with arguments glances intsallation script autoit check if autoit script is running detect script in pdf apps script convert docx to doc entity framework generate script google app script when user uses on edit protected range r library from conda environment batch job bash script first person movement script for godot

Browse Other Code Languages

CodeProZone