-
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.
Minor refactoring and updater execution (still WIN only)
- Loading branch information
Showing
18 changed files
with
382 additions
and
131 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 |
---|---|---|
|
@@ -2,4 +2,17 @@ | |
|
||
This is Scala implementation of client for [RBackup](https://github.com/jendakol/rbackup). | ||
|
||
Readme TBD :-) | ||
Readme TBD :-) | ||
|
||
## Build (release) | ||
``` | ||
#!/usr/bin/fish | ||
./.travis.sh | ||
env VERSION=$argv[1] \ | ||
SENTRY_DSN="https://[email protected]/1234" \ | ||
sbt ";clean;setVersionInSources;setSentryDsnInSources;dist" | ||
``` | ||
|
||
The SENTRY_DSN is optional. |
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ import monix.eval.Task | |
import monix.execution.{Cancelable, Scheduler} | ||
import org.http4s.Uri | ||
import play.api.inject.ApplicationLifecycle | ||
import updater.{AppVersion, Updater} | ||
import updater.Updater | ||
|
||
import scala.collection.generic.CanBuildFrom | ||
import scala.concurrent.Future | ||
|
@@ -38,9 +38,11 @@ class App @Inject()(backupSetsExecutor: BackupSetsExecutor, updater: Updater)(li | |
} | ||
|
||
object App { | ||
final val versionStr: String = "0.1.2" | ||
final val versionStr: String = "0.1.3" | ||
final val version: AppVersion = AppVersion(versionStr).getOrElse(throw new IllegalArgumentException("Could not parse versionStr")) | ||
|
||
final val SentryDsn: Option[String] = Some("https://[email protected]/1340234") | ||
|
||
type Result[A] = EitherT[Task, AppException, A] | ||
|
||
def pureResult[A](a: => A): Result[A] = { | ||
|
@@ -205,4 +207,6 @@ object App { | |
|
||
case class ServerSession(rootUri: Uri, sessionId: String, serverVersion: AppVersion) | ||
|
||
case class DeviceId(value: String) extends AnyVal | ||
case class DeviceId(value: String) { | ||
override def toString: String = value | ||
} |
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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package updater | ||
|
||
import better.files.File | ||
import com.typesafe.scalalogging.StrictLogging | ||
import lib.{AppVersion, DeviceId} | ||
|
||
import scala.language.postfixOps | ||
|
||
sealed trait ServiceUpdaterExecutor { | ||
def executeUpdate(currentVersion: AppVersion, newVersion: AppVersion, env: String, deviceId: DeviceId, dirWithUpdate: File): Unit | ||
} | ||
|
||
class WindowsServiceUpdaterExecutor extends ServiceUpdaterExecutor with StrictLogging { | ||
override def executeUpdate(currentVersion: AppVersion, | ||
newVersion: AppVersion, | ||
env: String, | ||
deviceId: DeviceId, | ||
dirWithUpdate: File): Unit = { | ||
logger.info(s"Starting the update with args: $currentVersion, $newVersion, $env, $deviceId, $dirWithUpdate") | ||
|
||
Runtime.getRuntime.exec( | ||
Array( | ||
"cmd", | ||
"/C", | ||
"start", | ||
"\"\"", | ||
"java", | ||
"-jar", | ||
"updater.jar", | ||
currentVersion.toString, | ||
newVersion.toString, | ||
env, | ||
deviceId.value, | ||
dirWithUpdate.pathAsString | ||
)) | ||
() | ||
} | ||
} | ||
|
||
class LinuxServiceUpdaterExecutor extends ServiceUpdaterExecutor { | ||
override def executeUpdate(currentVersion: AppVersion, | ||
newVersion: AppVersion, | ||
env: String, | ||
deviceId: DeviceId, | ||
dirWithUpdate: File): Unit = { | ||
Runtime.getRuntime.exec( | ||
Array( | ||
"/bin/bash", | ||
"-c", | ||
"restart_replace.sh", | ||
dirWithUpdate.pathAsString, | ||
"&", | ||
)) | ||
() | ||
} | ||
} |
Oops, something went wrong.