Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 4 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
45 core/api/shell/cron/functions
@@ -0,0 +1,45 @@
+#!/usr/bin/env zsh
+
+cron()
+{
+ trace_filter process2 || set -o xtrace
+ typeset _command _name
+ typeset -a __process_commands
+
+ __process_commands=(
+ "show"
+ "groups=list groups"
+ "group=show group"
+ "del group=remove group"
+ "add group=edit group"
+ )
+
+ if __sm.command.detect "$*" "${__process_commands[@]}"
+ then
+ _command="${__sm_command_dotted}"
+ shift "${__sm_command_words}"
+ else
+ __sm.log.fail "No command given.\nUsage: \ncron <command> ..."
+ fi
+
+ case "${_command}" in
+ (show|list.groups)
+ if __sm.cron.${_command}
+ then return 0
+ else return $?
+ fi
+ ;;
+ (show.group|remove.group|edit.group)
+ _name="$1"
+ shift || __sm.log.fail "Name name must be given after keyword '${_token}'"
+
+ if __sm.cron.${_command} "${_name}"
+ then return 0
+ else return $?
+ fi
+ ;;
+ (*)
+ __sm.log.fail "Cron API command '${_command}' s not handled."
+ ;;
+ esac
+}
View
1  core/api/shell/cron/includes
@@ -0,0 +1 @@
+internal/cron
View
8 core/api/shell/process2/functions
@@ -19,7 +19,7 @@ process2()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- __sm.log.__sm.log.fail "No command given.\nUsage: \npaths <command> ..."
+ __sm.log.fail "No command given.\nUsage: \nprocess2 <command> ..."
fi
while (( $# ))
@@ -48,10 +48,10 @@ process2()
;;
(command)
_command_arr=( "$@" )
- shift || __sm.log.fail "Command must be given after keyword '${_token}'"
+ shift $# || __sm.log.fail "Command must be given after keyword '${_token}'"
;;
(*)
- __sm.log.__sm.log.fail "Unknown token '${_token}'"
+ __sm.log.fail "Unknown token '${_token}'"
;;
esac
done
@@ -95,7 +95,7 @@ process2()
fi
;;
(*)
- __sm.log.__sm.log.fail "Process API command '${_command}' s not handled."
+ __sm.log.fail "Process2 API command '${_command}' s not handled."
;;
esac
}
View
11 core/cli/map
@@ -89,7 +89,18 @@ package=dev/package
publish=dev/publish
create=dev/create
json/get=json/get
+process2/start/silent=process2/process2_silent_start()
process2/start=process2/process2_start()
process2/stop=process2/process2_stop()
process2/restart=process2/process2_restart()
process2/running=process2/process2_running()
+process2/shedule=process2/process2_shedule()
+process2/unshedule=process2/process2_unshedule()
+process2/sheduled=process2/process2_sheduled()
+cron/show=cron/__sm.cron.show()
+cron/groups=cron/__sm.cron.list.groups()
+cron/group=cron/__sm.cron.show.group()
+cron/add/group=cron/__sm.cron.edit.group()
+cron/edit/group=cron/__sm.cron.edit.group()
+cron/show/group=cron/__sm.cron.show.group()
+cron/remove/group=cron/__sm.cron.remove.group()
View
1  core/cli/shell/cron/includes
@@ -0,0 +1 @@
+api/cron
View
49 core/cli/shell/process2/functions
@@ -9,6 +9,17 @@ process2_start()
command "$@"
}
+process2_silent_start()
+{
+ if process2 start \
+ name $1 \
+ timeout 10 \
+ command "$@"
+ then return 0
+ else return $?
+ fi
+}
+
process2_stop()
{
log step "Stoping $1" \
@@ -45,3 +56,41 @@ process2_running()
return ${_status}
fi
}
+
+process2_shedule()
+{
+ log step "Adding to cron every 5 minutes check $1"
+ if {
+ if which $1 | grep rvm >/dev/null
+ then rvm env --cron
+ fi
+ echo "*/5 * * * * cd \"$PWD\" ; \"$(which sm)\" process2 start silent $*"
+ } | cron edit group $1
+ then log step succ
+ else
+ typeset _status=$?
+ log step fail
+ return ${_status}
+ fi
+}
+
+process2_unshedule()
+{
+ log step "Removing from cron checking $1" \
+ cron remove group $1
+}
+
+process2_sheduled()
+{
+ log step "$1 ..."
+ if cron group $1 | grep "" >/dev/null
+ then
+ log_step_message="$1 sheduled."
+ log step succ
+ else
+ typeset _status=$?
+ log_step_message="$1 not sheduled"
+ log step fail
+ return ${_status}
+ fi
+}
View
1  core/cli/shell/process2/includes
@@ -1 +1,2 @@
api/process2
+api/cron

No commit comments for this range

Something went wrong with that request. Please try again.