Refactor raptor a bit
parent
bbcd7bc6ea
commit
bab5554cfe
|
@ -1,5 +1,6 @@
|
|||
|
||||
USING: kernel parser namespaces threads unix.process combinators.cleave ;
|
||||
USING: kernel parser namespaces threads sequences unix unix.process
|
||||
combinators.cleave bake ;
|
||||
|
||||
IN: raptor
|
||||
|
||||
|
@ -10,29 +11,29 @@ SYMBOL: reboot-hook
|
|||
SYMBOL: shutdown-hook
|
||||
SYMBOL: networking-hook
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: reload-raptor-config ( -- )
|
||||
"/etc/raptor/config.factor" run-file
|
||||
"/etc/raptor/cronjobs.factor" run-file ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
USING: sequences unix ;
|
||||
: fork-exec-wait ( pathname args -- )
|
||||
fork dup 0 = [ drop exec drop ] [ 2nip wait-for-pid drop ] if ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: forever ( quot -- ) [ call ] [ forever ] bi ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: start-service ( name -- ) "/etc/init.d/" swap " start" 3append system drop ;
|
||||
: stop-service ( name -- ) "/etc/init.d/" swap " stop" 3append system drop ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: fork-exec-wait ( pathname args -- )
|
||||
fork dup 0 = [ drop exec drop ] [ 2nip wait-for-pid ] if ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: respawn ( pathname args -- ) [ fork-exec-wait ] [ respawn ] 2bi ;
|
||||
|
||||
: start-gettys ( -- )
|
||||
[ "/sbin/getty" { "getty" "38400" "tty5" } respawn ] in-thread
|
||||
[ "/sbin/getty" { "getty" "38400" "tty6" } respawn ] in-thread ;
|
||||
: getty ( tty -- ) `{ "/sbin/getty" "38400" , } fork-exec-wait ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
@ -43,13 +44,6 @@ USING: io io.files io.streams.lines io.streams.plain io.streams.duplex
|
|||
[ <file-reader> ] [ <file-writer> ] bi <duplex-stream>
|
||||
[ listener ] with-stream ;
|
||||
|
||||
: forever ( quot -- ) [ call ] [ forever ] bi ;
|
||||
|
||||
: start-listeners ( -- )
|
||||
[ [ "/dev/tty2" tty-listener ] forever ] in-thread
|
||||
[ [ "/dev/tty3" tty-listener ] forever ] in-thread
|
||||
[ [ "/dev/tty4" tty-listener ] forever ] in-thread ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: start-networking ( -- ) networking-hook get call ;
|
||||
|
@ -59,3 +53,4 @@ USING: io io.files io.streams.lines io.streams.plain io.streams.duplex
|
|||
: shutdown ( -- ) shutdown-hook get call ;
|
||||
|
||||
MAIN: boot
|
||||
|
||||
|
|
Loading…
Reference in New Issue