rapierorg / telegram-bot-swift

Telegram Bot SDK for Swift (unofficial)
https://github.com/rapierorg/telegram-bot-swift/wiki
Apache License 2.0
374 stars 63 forks source link

Automatic update #5

Closed simonnarang closed 8 years ago

simonnarang commented 8 years ago

Is there a way to add automatic restarting for the bot when you save the main.swift file? Kind of like https://github.com/remy/nodemon

zmeyc commented 8 years ago

Simplest possible way is making a .sh file which calls it in a loop unless the exit status is 0.

It will be a good idea to send an email to admin on restart. Bot tries to handle most of the errors such as reconnections and exists only on critical errors.

zmeyc commented 8 years ago

It's not designed for multi process work, so monitoring tools are probably an overkill.

zmeyc commented 8 years ago

Oops, I misread the question. No, bot doesn't track modification date of it's source files. Xcode automatically restarts it on CMD-R, in console just call killall processname (I mapped a hotkey in VIM which saved the file then rebuilt and restarted the app).

zmeyc commented 8 years ago

Modify build target in Makefile so it kills the process, deletes the binary, builds then runs it. Then in ~/.vimrc:

map <F9> :mak<CR>

In case of error the editor will parse compilation error and position on error, if no errors during build - a binary will be produced and runned.

But I recommend using Xcode instead.

simonnarang commented 8 years ago

I am editing the files in Xcode... However, I don't know how to turn the folder into an Xcode project/workspace. Thanks

zmeyc commented 8 years ago

1) swift build -X This will create xcodeproj.

2) In xcodeproj there will be two targets, switch the active target to the bottom one.

3) Add token to Xcode's environment variables in "Edit Scheme..." menu and/or set Working Folder to bot's folder.

CMD-R should now run the app.

Optionally, remove all .swift files in the project then re-add them to get proper folder structure (it's flat by default).

simonnarang commented 8 years ago

Wow now this is a lot more familiar. Thanks again