diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..33b997b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,26 @@ +# Author: Evgeniy "arcanis" Alexeev +# Maintainer: Evgeniy "arcanis" Alexeev + +pkgname=queued +pkgver=1.0.0 +pkgrel=1 +pkgdesc="Daemon for starting jobs to queue of calculations" +arch=('any') +url="https://github.com/arcan1s/queued" +license=("GPL") +makedeps=('git') +source=(https://github.com/arcan1s/queued/releases/download/V.${pkgver}/${pkgname}-${pkgver}.tar.xz) +md5sums=('d93c8cf20804b07b47645b0c43d45d3d') +backup=('etc/queued.conf') + +package() +{ + # daemon + install -D -m755 "${srcdir}/${pkgname}/usr/bin/queued" "${pkgdir}/usr/bin/queued" + + # service + install -D -m644 "${srcdir}/${pkgname}/usr/lib/systemd/system/queued.service" \ + "${pkgdir}/usr/lib/systemd/system/queued.service" + install -D -m644 "${srcdir}/${pkgname}/etc/queued.conf" \ + "${pkgdir}/etc/queued.conf" +} diff --git a/README.md b/README.md index 0a0001d..667aff5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,46 @@ queued ====== -Daemon for starting jobs to queue of calculations +Information +----------- +Daemon for starting jobs to queue of calculations. To start deamon just run `systemctl start queued` as root. + +help message +------------ + queued [ -jd | --jobdir /var/lib/queued/job ] [ --priority 0 ] [ -q | --queuefile /var/lib/queued/queue ] [ -u | --user root ] [ -wd | --workdir /var/lib/queued/work ] [-v | --version ] [ -h | --help ] + + Parametrs: + -jd --jobdir PATH - path to job directory. Default is '/var/lib/queued/job' + --priority NUM - defalut priority. Default is '0' + -q --queuefile PATH - path to queue file. Default is '/var/lib/queued/queue' + -u --user USERNAME - start jobs by user. Default is 'root' + -wd --workdir PATH - path to work directory. Default is '/var/lib/queued/work' + -v --version - show version and exit + -h --help - show this help and exit + +Configuration +------------- +All settings are stored in `/etc/queued.conf`. After edit them you must restart daemon (`systemctl restart queued`). + +How-to run jobs +--------------- +* create shell script with the command (it have a name `script.sh` for example) +* create priority file (`script.sh.pr`) with the job priority if it is needed +* create user file (`script.sh.user`) with the job username if it is needed +* copy files to `$WORKDIR` + + +Instruction +=========== + +Dependencies +------------ +* bash (sed, awk, etc) +* systemd + +Installation +------------ +* download sources +* copy source to `/`: + + sudo cp ../queued/* / diff --git a/queued-1.0.0.tar.xz b/queued-1.0.0.tar.xz new file mode 100644 index 0000000..3256961 Binary files /dev/null and b/queued-1.0.0.tar.xz differ diff --git a/sources/queued b/sources/queued index f32387d..fe06ac5 100755 --- a/sources/queued +++ b/sources/queued @@ -120,6 +120,7 @@ cd / [ -d "$WORKDIR/$FILE" ] && continue FILE_EXT="${FILE##*.}" [ "$FILE_EXT" = "pr" ] && continue + [ "$FILE_EXT" = "user" ] && continue [ -e "$QUEUEFILE" ] && grep --quiet "$WORKDIR/$FILE" "$QUEUEFILE" && continue echo "[II] Adding file '$FILE' to list" if [ -e "$WORKDIR/$FILE".pr ]; then @@ -168,10 +169,10 @@ cd / CURJOB=$(tail -1 "$QUEUEFILE" | awk -F "==" '{print $2}') [ -z "$CURJOB" ] && break sed -i '$d' "$QUEUEFILE" - [ -e "$CURJOB".pr ] && mv "$CURJOB".pr "$JOBDIR/$(basename "$CURJOB")".pr - mv "$CURJOB" "$JOBDIR/$(basename "$CURJOB")" 2> /dev/null || break + [ -e "$CURJOB".user ] && CUR_USER="$(cat "$CURJOB".user)" || CUR_USER="$STARTASUSER" + mv "$CURJOB"* "$JOBDIR/" 2> /dev/null || break echo "[II] Running job '$CURJOB'" - su -c "/bin/sh "$JOBDIR/$(basename "$CURJOB")"" $STARTASUSER &> "$JOBDIR/$(basename "$CURJOB")".log & + su -c "/bin/sh "$JOBDIR/$(basename "$CURJOB")" &> "$JOBDIR/$(basename "$CURJOB")".log" $CUR_USER & ) else echo "[II] You have a running job"