reduardo7 / bash-service-manager Goto Github PK
View Code? Open in Web Editor NEWBash Script's for Service Manager
License: MIT License
Bash Script's for Service Manager
License: MIT License
Hi,
I want to use bash-service-manager for controlling starting and stopping of a python script (logtooltje.py)
Starting the python script via service-manager goes fine. But it won't stop.
I noticed that for some reason the servicemanager (named logdaemon in my example) is is started twice. When I perform "logdaemon stop", the PID-file is removed and one logdaemon proces is killed. However there is still one logdaemon process running, including the python script.
Below the commands to visualize the issue.
Your help is much appreciated.
+++++++++++++++++
[goldeneye@server-x daemon]$ cat logdaemon
#!/usr/bin/bash
export PID_FILE_PATH="/tmp/my-service.pid"
export LOG_FILE_PATH="/tmp/my-service.log"
export LOG_ERROR_FILE_PATH="/tmp/my-service.error.log"
. services.sh
run-logtooltje() {
python logtooltje.py
}
action="$1"
serviceName="logtooltje"
workDir="/home/plas109/flowanalysis/daemon"
command="run-logtooltje"
serviceMenu "$action" "$serviceName" "$command" "$workdir"
++++++++++++++++++++++++++++++++++++++++++++
[goldeneye@server-x daemon]$ ./logdaemon start
[goldeneye@server-x daemon]$ ps -ef | grep logda
goldeneye 6251 1 0 23:19 pts/4 00:00:00 /usr/bin/bash ./logdaemon start
goldeneye 6252 6251 0 23:19 pts/4 00:00:00 /usr/bin/bash ./logdaemon start
goldeneye 6257 22139 0 23:19 pts/4 00:00:00 grep --color=auto logda
[goldeneye@server-x daemon]$ ps -ef | grep logto
goldeneye 6253 6252 0 23:19 pts/4 00:00:00 python logtooltje.py
goldeneye 6259 22139 0 23:19 pts/4 00:00:00 grep --color=auto logto
[goldeneye@server-x daemon]$ cat /tmp/my-service.pid
6251
Now stopping the servicemanager:
[goldeneye@server-x daemon]$ ./logdaemon stop
[goldeneye@server-x daemon]$ cat /tmp/my-service.pid
cat: /tmp/my-service.pid: No such file or directory
[goldeneye@server-x daemon]$ ps -ef | grep logdaemon
goldeneye 6252 1 0 23:19 pts/4 00:00:00 /usr/bin/bash ./logdaemon start
goldeneye 6286 22139 0 23:20 pts/4 00:00:00 grep --color=auto logdaemon
[goldeneye@server-x daemon]$ ps -ef | grep logtooltje.py
goldeneye 6253 6252 0 23:19 pts/4 00:00:00 python logtooltje.py
goldeneye 6290 22139 0 23:20 pts/4 00:00:00 grep --color=auto logtooltje.py
Python script is still running
A simple bash
export PID_FILE_PATH="/tmp/app.pid"
export LOG_FILE_PATH="/var/log/app/app.log"
export LOG_ERROR_FILE_PATH="/var/log/app/error.log"
DIR=$(dirname $(readlink -f $0))
# Import or paste "services.sh"
. $DIR/services.sh
run-app() {
$DIR/app $DIR/predixy.conf
}
action="$1"
serviceName="app"
command="run-app"
serviceMenu "$action" "$serviceName" "$command"
Run it in a relative path
cd /folder/to/
./this.sh start
ps aux | grep app
1 process like this:
/folder/to/app /folder/to/app.conf
Run in a full path
/folder/to/this.sh start
3 processes
bash /folder/to/this.sh start <--- PID is this process
bash /folder/to/this.sh start
/folder/to/app /folder/to/app.conf
bash-service-manager/services.sh
Line 63 in 03cc81b
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.