forked from RotherOSS/otobo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue RotherOSS#51: first stab at running Daemon and Cron in own shell
Not really tested yet.
- Loading branch information
1 parent
316e3f0
commit 0ba0fcc
Showing
3 changed files
with
49 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
# no command line arguments are handled | ||
# root handles 'cron' and defers 'web' to the OTOBO user | ||
if [ $UID -eq 0 ]; then | ||
echo "otobo_user: $OTOBO_USER"; | ||
if [ "$1" = "cron" ]; then | ||
# Start the OTOBO Daemon. | ||
# The Daemon will exit immediately when SecureMode = 0. | ||
# But this is OK, as Cron will restart it and it will run when SecureMode = 1. | ||
su -c "./bin/otobo.Daemon.pl start" "$OTOBO_USER" | ||
|
||
# Start up OTOBO Daemon and the webserver | ||
# Run a watchdog over the Daemon via Cron | ||
# assume that we are in /opt/otobo | ||
su -c "mkdir -p var/tmp" "$OTOBO_USER" | ||
|
||
# assume that we are in /opt/otobo | ||
mkdir -p var/tmp | ||
# set up the cronjobs as they are declared in var/cron | ||
su -c "./bin/Cron.sh start" "$OTOBO_USER" | ||
|
||
# set up the cronjobs as they are declared in var/cron | ||
./bin/Cron.sh start | ||
# Run a watchdog over the Daemon via Cron | ||
# run cron in the foreground | ||
exec cron -f | ||
# nothing will be executed beyond that line, | ||
# because exec replaces running process with the new one | ||
fi | ||
|
||
# Start the Daemon. | ||
# The Daemon will exit immediately when SecureMode = 0. | ||
# But this is OK, as Cron will restart it and it will run when SecureMode = 1. | ||
./bin/otobo.Daemon.pl start | ||
# everything else is run as otobo | ||
exec su "$OTOBO_USER" "$0" -- "$@" | ||
# nothing will be executed beyond that line, | ||
# because exec replaces running process with the new one | ||
fi | ||
|
||
# maintainance jobs | ||
# TODO: decide whether it makes sense to run these jobs on startup | ||
#perl ./bin/otobo.Console.pl Maint::Config::Rebuild | ||
#perl ./bin/otobo.Console.pl Maint::Cache::Delete | ||
echo "The command $1 will be run from user $UID." | ||
|
||
# Start the webserver | ||
plackup --server Gazelle -R Kernel,bin/psgi-bin/otobo.psgi --port 5000 bin/psgi-bin/otobo.psgi | ||
if [ "$1" = "web" ]; then | ||
# maintainance jobs | ||
# TODO: decide whether it makes sense to run these jobs on startup | ||
#perl ./bin/otobo.Console.pl Maint::Config::Rebuild | ||
#perl ./bin/otobo.Console.pl Maint::Cache::Delete | ||
|
||
# Start the webserver | ||
plackup --server Gazelle -R Kernel,bin/psgi-bin/otobo.psgi --port 5000 bin/psgi-bin/otobo.psgi | ||
|
||
else | ||
echo "Unknown option $1. Exiting." | ||
exit -1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters