info() and fixes
* Info function * Fix: removing the pidfile Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
		
							
								
								
									
										19
									
								
								ssm
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								ssm
									
									
									
									
									
								
							| @@ -27,14 +27,16 @@ svc() { | |||||||
| 		kill -n "$service_stop_signal" "$job_pid" | 		kill -n "$service_stop_signal" "$job_pid" | ||||||
|  |  | ||||||
| 		pid_wait "$job_pid" && { | 		pid_wait "$job_pid" && { | ||||||
| 			rm -f $svc_pidfile $service_ready_flag | 			rm -f "$svc_pidfile" "$service_ready_flag" | ||||||
| 		} | 		} | ||||||
| 	}; trap 'svc::cleanup' TERM | 	} | ||||||
|  |  | ||||||
| 	"$@" & job_pid=$! | 	"$@" & job_pid=$! | ||||||
|  |  | ||||||
| 	printf '%s' "$job_pid" > "$svc_pidfile" | 	printf '%s' "$job_pid" > "$svc_pidfile" | ||||||
| 	wait "$job_pid" | 	wait "$job_pid" | ||||||
|  |  | ||||||
|  | 	svc::cleanup | ||||||
| } | } | ||||||
|  |  | ||||||
| ## Respawn | ## Respawn | ||||||
| @@ -49,6 +51,8 @@ respawn() { | |||||||
| 			wait "${jobs[@]}" | 			wait "${jobs[@]}" | ||||||
| 		fi | 		fi | ||||||
|  |  | ||||||
|  | 		rm -vf "$svc_pidfile" "$service_ready_flag" &>>/tmp/ssm.log | ||||||
|  |  | ||||||
| 		exit 0 | 		exit 0 | ||||||
| 	}; trap 'respawn::cleanup' TERM | 	}; trap 'respawn::cleanup' TERM | ||||||
|  |  | ||||||
| @@ -251,6 +255,17 @@ super_stop() { | |||||||
| 	fi | 	fi | ||||||
| } | } | ||||||
|  |  | ||||||
|  | info() { | ||||||
|  | 	declare info=() | ||||||
|  |  | ||||||
|  | 	printf "%12s: %s\n" \ | ||||||
|  | 		"Name"    "$service_name" \ | ||||||
|  | 		"Exec"    "$service_command ${service_args[*]}" \ | ||||||
|  | 		"Respawn" "${service_respawn:-false}" \ | ||||||
|  | 		"PIDfile" "${service_pidfile:-none}" \ | ||||||
|  | 		"PID"     "${service_pid:-none}" | ||||||
|  | } | ||||||
|  |  | ||||||
| result() { | result() { | ||||||
| 	declare rc=$1; shift | 	declare rc=$1; shift | ||||||
| 	declare -A msgs | 	declare -A msgs | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user