mirror of
https://github.com/FakeTV/pseudo-channel.git
synced 2025-12-21 02:33:30 +00:00
Added startstop.sh file to easily start / stop PseudoChannel.py in the background. Also loggin support in ./pseudo-channel.log
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,3 +9,5 @@ old/
|
||||
pseudo-channel.db
|
||||
*.db-journal
|
||||
env/
|
||||
*.log
|
||||
*.pid
|
||||
|
||||
@@ -16,6 +16,7 @@ from plexapi.server import PlexServer
|
||||
import sys
|
||||
import datetime
|
||||
from datetime import time
|
||||
import logging
|
||||
import calendar
|
||||
import itertools
|
||||
import argparse
|
||||
@@ -56,6 +57,8 @@ class PseudoChannel():
|
||||
|
||||
def __init__(self):
|
||||
|
||||
logging.basicConfig(filename="pseudo-channel.log", level=logging.INFO)
|
||||
|
||||
self.db = PseudoChannelDatabase("pseudo-channel.db")
|
||||
|
||||
self.controller = PseudoDailyScheduleController(
|
||||
@@ -1060,7 +1063,7 @@ if __name__ == '__main__':
|
||||
|
||||
"""
|
||||
|
||||
|
||||
logging.info("+++++ Running PseudoChannel.py -r")
|
||||
|
||||
def trigger_what_should_be_playing_now():
|
||||
|
||||
@@ -1233,6 +1236,8 @@ if __name__ == '__main__':
|
||||
|
||||
if sleep_before_triggering_play_now:
|
||||
|
||||
logging.info("+++++ Successfully started PseudoChannel.py")
|
||||
|
||||
trigger_what_should_be_playing_now()
|
||||
|
||||
sleep_before_triggering_play_now = 0
|
||||
|
||||
46
startstop.sh
Executable file
46
startstop.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
# file: startstop.sh
|
||||
|
||||
#----
|
||||
# Simple script to start / stop PseudoChannel.py
|
||||
#----
|
||||
|
||||
#----
|
||||
# To Use:
|
||||
# Just run: "./startstop.sh". If the process is running it will stop it or it will start it if not.
|
||||
#----
|
||||
|
||||
#----BEGIN EDITABLE VARS----
|
||||
|
||||
pid_file=running.pid
|
||||
|
||||
output_pid_path=.
|
||||
|
||||
python_to_use="$(which python)"
|
||||
|
||||
#----END EDITABLE VARS-------
|
||||
|
||||
if [ ! -e $output_pid_path/$pid_file ]; then
|
||||
|
||||
# If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it.
|
||||
nohup $python_to_use ./PseudoChannel.py -m -r > /dev/null 2>&1 & echo $! > $output_pid_path/$pid_file
|
||||
|
||||
echo "Started PseudoChannel.py @ Process: $!"
|
||||
echo "Created $pid_file file in $output_pid_path dir"
|
||||
|
||||
else
|
||||
|
||||
# If the running.pid exists, read it & try to kill the process if it exists, then delete it.
|
||||
the_pid=$(<$output_pid_path/$pid_file)
|
||||
rm $output_pid_path/$pid_file
|
||||
echo "Deleted $pid_file file in $output_pid_path dir"
|
||||
kill $the_pid
|
||||
while [ -e /proc/$the_pid ]
|
||||
do
|
||||
echo "PseudoChannel.py @: $the_pid is still running"
|
||||
sleep .6
|
||||
done
|
||||
echo "PseudoChannel.py @: $the_pid has finished"
|
||||
|
||||
fi
|
||||
Reference in New Issue
Block a user