@@ -109,27 +109,28 @@ func startAllSites() {
109
109
sitesDir := "/home/fly"
110
110
foundSite := false
111
111
112
- filepath .Walk (sitesDir , func (path string , info os.FileInfo , err error ) error {
113
- if err != nil {
114
- return err
115
- }
112
+ entries , err := os .ReadDir (sitesDir )
113
+ if err != nil {
114
+ fmt .Printf ("Error reading directory %s: %v\n " , sitesDir , err )
115
+ return
116
+ }
116
117
117
- // Skip hidden directories
118
- if info .IsDir () && strings .HasPrefix (info .Name (), "." ) {
119
- return filepath .SkipDir
120
- }
118
+ for _ , entry := range entries {
119
+ if entry .IsDir () {
120
+ // Skip hidden directories
121
+ if strings .HasPrefix (entry .Name (), "." ) {
122
+ continue
123
+ }
121
124
122
- if info . IsDir () && filepath . Base ( path ) != "fly" {
125
+ path := filepath . Join ( sitesDir , entry . Name ())
123
126
composePath := filepath .Join (path , "docker-compose.yml" )
124
127
if _ , err := os .Stat (composePath ); err == nil {
125
128
fmt .Printf ("Starting site in %s\n " , path )
126
129
docker .RunCompose (composePath , "up" , "-d" )
127
130
foundSite = true
128
131
}
129
132
}
130
-
131
- return nil
132
- })
133
+ }
133
134
134
135
if ! foundSite {
135
136
fmt .Println ("No sites found to start." )
@@ -139,26 +140,29 @@ func startAllSites() {
139
140
func stopAllSites () {
140
141
sitesDir := "/home/fly"
141
142
foundSite := false
142
- filepath .Walk (sitesDir , func (path string , info os.FileInfo , err error ) error {
143
- if err != nil {
144
- return err
145
- }
146
143
147
- // Skip hidden directories
148
- if info .IsDir () && strings .HasPrefix (info .Name (), "." ) {
149
- return filepath .SkipDir
150
- }
144
+ entries , err := os .ReadDir (sitesDir )
145
+ if err != nil {
146
+ fmt .Printf ("Error reading directory %s: %v\n " , sitesDir , err )
147
+ return
148
+ }
149
+
150
+ for _ , entry := range entries {
151
+ if entry .IsDir () {
152
+ // Skip hidden directories
153
+ if strings .HasPrefix (entry .Name (), "." ) {
154
+ continue
155
+ }
151
156
152
- if info . IsDir () && filepath . Base ( path ) != "fly" {
157
+ path := filepath . Join ( sitesDir , entry . Name ())
153
158
composePath := filepath .Join (path , "docker-compose.yml" )
154
159
if _ , err := os .Stat (composePath ); err == nil {
155
- fmt .Printf ("Stopping site in %s\n " , path )
156
- docker .RunCompose (composePath , "down " )
160
+ fmt .Printf ("Starting site in %s\n " , path )
161
+ docker .RunCompose (composePath , "up" , "-d " )
157
162
foundSite = true
158
163
}
159
164
}
160
- return nil
161
- })
165
+ }
162
166
163
167
if ! foundSite {
164
168
fmt .Println ("No sites found to stop." )
0 commit comments