Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

As @vnp @vnp pointed out, the sleep 1 calls are dodgy, I did not fix that. To fix that, look for pid files created by those services, and use them to check if the service is still running or not.

As @vnp pointed out, the sleep 1 calls are dodgy, I did not fix that. To fix that, look for pid files created by those services, and use them to check if the service is still running or not.

As @vnp pointed out, the sleep 1 calls are dodgy, I did not fix that. To fix that, look for pid files created by those services, and use them to check if the service is still running or not.

replaced http://askubuntu.com/ with https://askubuntu.com/
Source Link

Ideally, you should standardize everything: make it possible to start/stop/restart your custom php-fpm and nginx just like other services. That way you can remove the service-specific logic from this script (doesn't really belong here anyway), and then it can work for any service you throw at it. Unfortunately I don't know enough Ubuntu to guide you, but I'm sure the guys on askubuntu.com askubuntu.com can help with that.

Ideally, you should standardize everything: make it possible to start/stop/restart your custom php-fpm and nginx just like other services. That way you can remove the service-specific logic from this script (doesn't really belong here anyway), and then it can work for any service you throw at it. Unfortunately I don't know enough Ubuntu to guide you, but I'm sure the guys on askubuntu.com can help with that.

Ideally, you should standardize everything: make it possible to start/stop/restart your custom php-fpm and nginx just like other services. That way you can remove the service-specific logic from this script (doesn't really belong here anyway), and then it can work for any service you throw at it. Unfortunately I don't know enough Ubuntu to guide you, but I'm sure the guys on askubuntu.com can help with that.

added 89 characters in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
#!/bin/sh -e
NGINX=/home/prahlad/programs/nginx-1.6.0/sbin/nginx
PHP=/home/prahlad/programs/php-5.4/sbin/php-fpm
PHP_NAME=$(basename $PHP)
startstop_service() {
 cmd=1ドル
 name=2ドル
 sudo service $name $cmd
}
startstop_nginx() {
 cmd=1ドル
 case $cmd in
 stop) $NGINX -s stop ;;
 start) $NGINX ;;
 restart)
 $NGINX -s stop
 sleep 1
 $NGINX
 ;;
 esac
}
startstop_php() {
 cmd=1ドル
 case $cmd in
 stop) pkill $PHP_NAME ;;
 start) $PHP ;;
 restart)
 pkill $PHP_NAME
 sleep 1
 $PHP
 ;;
 esac
}
case "1ドル" in
 start|stop|restart) cmd=1ドル ;;
 *)
 shift
  servicenames=${@-servicenames}
 echo "usage: 0ドル [start|stop|restart] servicenames";$servicenames"
  exit 1
esac
shift
for name; do
 case "$name" in
 php-fpm) startstop_php $cmd ;;
 nginx) startstop_nginx $cmd ;;
 *) startstop_service $cmd $name ;;
 esac
done
#!/bin/sh -e
NGINX=/home/prahlad/programs/nginx-1.6.0/sbin/nginx
PHP=/home/prahlad/programs/php-5.4/sbin/php-fpm
PHP_NAME=$(basename $PHP)
startstop_service() {
 cmd=1ドル
 name=2ドル
 sudo service $name $cmd
}
startstop_nginx() {
 cmd=1ドル
 case $cmd in
 stop) $NGINX -s stop ;;
 start) $NGINX ;;
 restart)
 $NGINX -s stop
 sleep 1
 $NGINX
 ;;
 esac
}
startstop_php() {
 cmd=1ドル
 case $cmd in
 stop) pkill $PHP_NAME ;;
 start) $PHP ;;
 restart)
 pkill $PHP_NAME
 sleep 1
 $PHP
 ;;
 esac
}
case "1ドル" in
 start|stop|restart) cmd=1ドル ;;
 *) echo "usage: 0ドル [start|stop|restart] servicenames"; exit 1
esac
shift
for name; do
 case "$name" in
 php-fpm) startstop_php $cmd ;;
 nginx) startstop_nginx $cmd ;;
 *) startstop_service $cmd $name ;;
 esac
done
#!/bin/sh -e
NGINX=/home/prahlad/programs/nginx-1.6.0/sbin/nginx
PHP=/home/prahlad/programs/php-5.4/sbin/php-fpm
PHP_NAME=$(basename $PHP)
startstop_service() {
 cmd=1ドル
 name=2ドル
 sudo service $name $cmd
}
startstop_nginx() {
 cmd=1ドル
 case $cmd in
 stop) $NGINX -s stop ;;
 start) $NGINX ;;
 restart)
 $NGINX -s stop
 sleep 1
 $NGINX
 ;;
 esac
}
startstop_php() {
 cmd=1ドル
 case $cmd in
 stop) pkill $PHP_NAME ;;
 start) $PHP ;;
 restart)
 pkill $PHP_NAME
 sleep 1
 $PHP
 ;;
 esac
}
case "1ドル" in
 start|stop|restart) cmd=1ドル ;;
 *)
 shift
  servicenames=${@-servicenames}
 echo "usage: 0ドル [start|stop|restart] $servicenames"
  exit 1
esac
shift
for name; do
 case "$name" in
 php-fpm) startstop_php $cmd ;;
 nginx) startstop_nginx $cmd ;;
 *) startstop_service $cmd $name ;;
 esac
done
deleted 36 characters in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
deleted 19 characters in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
added 1 character in body
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
Source Link
janos
  • 112.9k
  • 15
  • 154
  • 396
Loading
lang-bash

AltStyle によって変換されたページ (->オリジナル) /